Changeset 51833 in vbox
- Timestamp:
- Jul 3, 2014 7:20:56 AM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 94681
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/libs/xpcom18a4/nsprpub/pr/src/io/prprf.c
r21149 r51833 331 331 ** form. 332 332 ** 333 ** XXX stop using s printf to convert floating point333 ** XXX stop using snprintf to convert floating point 334 334 */ 335 335 static int cvt_f(SprintfState *ss, double d, const char *fmt0, const char *fmt1) … … 339 339 int amount = fmt1 - fmt0; 340 340 341 PR_ASSERT((amount > 0) && (amount < sizeof(fin))); 342 if (amount >= sizeof(fin)) { 343 /* Totally bogus % command to sprintf. Just ignore it */ 341 if (amount <= 0 || amount >= sizeof(fin)) { 342 /* Totally bogus % command to snprintf. Just ignore it */ 344 343 return 0; 345 344 } … … 347 346 fin[amount] = 0; 348 347 349 /* Convert floating point using the native s printf code */348 /* Convert floating point using the native snprintf code */ 350 349 #ifdef DEBUG 351 350 { … … 357 356 } 358 357 #endif 359 sprintf(fout, fin, d); 360 361 /* 362 ** This assert will catch overflow's of fout, when building with 363 ** debugging on. At least this way we can track down the evil piece 364 ** of calling code and fix it! 365 */ 366 PR_ASSERT(strlen(fout) < sizeof(fout)); 358 memset(fout, 0, sizeof(fout)); 359 snprintf(fout, sizeof(fout), fin, d); 360 /* Explicitly null-terminate fout because on Windows snprintf doesn't 361 * append a null-terminator if the buffer is too small. */ 362 fout[sizeof(fout) - 1] = '\0'; 367 363 368 364 return (*ss->stuff)(ss, fout, strlen(fout));
Note:
See TracChangeset
for help on using the changeset viewer.