[CDRIVER-979] bson_strncpy can abort on Windows Created: 01/Nov/15  Updated: 03/May/17  Resolved: 03/Nov/15

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

Type: Bug Priority: Major - P3
Reporter: A. Jesse Jiryu Davis Assignee: A. Jesse Jiryu Davis
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

On platforms where bson_strncpy can call strncpy, if the destination is too small to copy the whole string, bson_strncpy truncates it to fit. On Windows it calls strcpy_s, which aborts the program if the source string is too long.

On Windows bson_strncpy should call strncpy_s (with an "n") instead, which accepts a "_TRUNCATE" option that behaves like standard strncpy.



 Comments   
Comment by Githook User [ 03/Nov/15 ]

Author:

{u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}

Message: CDRIVER-979 bson_strncpy aborts on windows

On platforms where bson_strncpy can call strncpy, if the destination is too
small to copy the whole string, bson_strncpy truncates it to fit. On Windows it
calls strcpy_s, which aborts the program if the source string is too long.

On Windows bson_strncpy should call strncpy_s (with an "n") instead, which
accepts a "_TRUNCATE" option that behaves like standard strncpy.
Branch: master
https://github.com/mongodb/libbson/commit/9e37125aeb62814a0c9852c00ba9dc37eab441f5

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