[SERVER-7253] Do not use indirect pointer to call 'snprintf' Created: 04/Oct/12 Updated: 11/Jul/16 Resolved: 04/Oct/12 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Internal Code |
| Affects Version/s: | 2.0.7, 2.2.0 |
| Fix Version/s: | 2.2.2, 2.3.0 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Tad Marshall | Assignee: | Tad Marshall |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||
| Backwards Compatibility: | Minor Change | ||||
| Operating System: | ALL | ||||
| Participants: | |||||
| Description |
|
In src/mongo/bson/util/builder.h in lines 250 to 256, we create a static initializer used to call sprintf_s on Windows or snprintf on other platforms. This makes it possible to crash at startup if another static initializer tries to use this function pointer before this one has run. Since the order in which static initializers run is unspecified by the C++ standard, this should be coded differently. Since Windows has a '_snprintf' function that does what 'snprintf' does on other platforms, this code can be replaced by a macro. |
| Comments |
| Comment by auto [ 06/Nov/12 ] |
|
Author: {u'date': u'2012-10-04T11:58:16Z', u'email': u'tad@10gen.com', u'name': u'Tad Marshall'}Message: Call _snprintf on Windows or snprintf on other platforms directly instead |
| Comment by Tad Marshall [ 04/Oct/12 ] |
|
Suggest backport to 2.0 and 2.2. |
| Comment by auto [ 04/Oct/12 ] |
|
Author: {u'date': u'2012-10-04T04:58:16-07:00', u'email': u'tad@10gen.com', u'name': u'Tad Marshall'}Message: Call _snprintf on Windows or snprintf on other platforms directly instead |