Mercurial > dwindows
comparison dwcompat.c @ 1989:1dd49705bd1a
Fix potential buffer overflow scenarios, reported by gcc fortify.
Removed OS/2 #ifdef since newer gcc libc supports snprtinf() ...
VisualAge and other compilers may not support it, but the fixes
for this belong in the header file. Will test soon.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Mon, 16 Sep 2019 08:58:58 +0000 |
parents | cb5f9aa9aebb |
children | 433b7c772ff0 |
comparison
equal
deleted
inserted
replaced
1988:197f9463efa8 | 1989:1dd49705bd1a |
---|---|
449 index++; | 449 index++; |
450 } | 450 } |
451 endmntent(fp); | 451 endmntent(fp); |
452 } | 452 } |
453 #endif | 453 #endif |
454 #elif defined(__OS2__) | 454 #else |
455 /* No snprintf() on OS/2 ??? */ | 455 snprintf(buf, len, "Drive %c", (char)drive + 'A' - 1); |
456 len = len; | |
457 sprintf(buf, "Drive %c", (char)drive + 'A' - 1); | |
458 #else | |
459 _snprintf(buf, len, "Drive %c", (char)drive + 'A' - 1); | |
460 #endif | 456 #endif |
461 } | 457 } |
462 | 458 |
463 void API setfileinfo(char *filename, char *url, char *logfile) | 459 void API setfileinfo(char *filename, char *url, char *logfile) |
464 { | 460 { |
465 time_t ltime; | 461 time_t ltime; |
466 struct tm *tm; | 462 struct tm *tm; |
467 char buffer[200], timebuf[200]; | 463 char buffer[250], timebuf[200]; |
468 #ifdef __OS2__ | 464 #ifdef __OS2__ |
469 const unsigned fea2listsize = 6000; | 465 const unsigned fea2listsize = 6000; |
470 char *pData; | 466 char *pData; |
471 EAOP2 eaop2; | 467 EAOP2 eaop2; |
472 PFEA2 pFEA2; | 468 PFEA2 pFEA2; |
476 | 472 |
477 ltime = time(NULL); | 473 ltime = time(NULL); |
478 | 474 |
479 tm = localtime(<ime); | 475 tm = localtime(<ime); |
480 | 476 |
481 strftime(timebuf, 200, "%c", tm); | 477 strftime(timebuf, sizeof(timebuf), "%c", tm); |
482 | 478 |
483 sprintf(buffer, "%s %s", url, timebuf); | 479 snprintf(buffer, sizeof(buffer), "%s %s", url, timebuf); |
484 | 480 |
485 #ifdef __OS2__ | 481 #ifdef __OS2__ |
486 logfile = logfile; | 482 logfile = logfile; |
487 eaop2.fpGEA2List = 0; | 483 eaop2.fpGEA2List = 0; |
488 eaop2.fpFEA2List = (PFEA2LIST)malloc(fea2listsize); | 484 eaop2.fpFEA2List = (PFEA2LIST)malloc(fea2listsize); |