[CDRIVER-3489] Fix and deduplicate safe isspace checks Created: 16/Jan/20  Updated: 28/Oct/23  Resolved: 30/Jan/20

Status: Closed
Project: C Driver
Component/s: None
Affects Version/s: None
Fix Version/s: 1.16.1

Type: Improvement Priority: Trivial - P5
Reporter: Kevin Albertson Assignee: Kevin Albertson
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to CDRIVER-2894 Migrate Windows MongoDB 4.4/latest te... Closed

 Description   

CDRIVER-2894 introduced three occurrences of the logic for calling isspace after checking the bounds of the argument, like:

c >= -1 && c <= 255 && isspace (c)

There are checks in libbson, once in libmongoc, and once in the common library. We should probably refactor this into one function, perhaps named isspace_safe either in bson-string.h or somewhere in common library.

Additionally, the check in common-b64.c checks with an unsigned char, making the comparison of -1 redundant and triggering an autological warning.



 Comments   
Comment by Githook User [ 30/Jan/20 ]

Author:

{'username': 'kevinAlbs', 'name': 'Kevin Albertson', 'email': 'kevin.albertson@mongodb.com'}

Message: CDRIVER-3489 add bson_isspace
Branch: r1.16
https://github.com/mongodb/mongo-c-driver/commit/501e0d86ec95a0177d926e71c7bee379ef5d76b7

Comment by Githook User [ 30/Jan/20 ]

Author:

{'username': 'kevinAlbs', 'name': 'Kevin Albertson', 'email': 'kevin.albertson@mongodb.com'}

Message: CDRIVER-3489 add bson_isspace
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/6ef8c161aeba80bd99d3fa06ebc3550d252f9296

Generated at Wed Feb 07 21:18:11 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.