# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1568624338 0 # Node ID 1dd49705bd1a9fa9c1c10a49eb11888a7ee06b1f # Parent 197f9463efa8d808aedf426923cf830b7e61ecc4 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. diff -r 197f9463efa8 -r 1dd49705bd1a dwcompat.c --- a/dwcompat.c Mon Sep 16 00:16:36 2019 +0000 +++ b/dwcompat.c Mon Sep 16 08:58:58 2019 +0000 @@ -451,12 +451,8 @@ endmntent(fp); } #endif -#elif defined(__OS2__) - /* No snprintf() on OS/2 ??? */ - len = len; - sprintf(buf, "Drive %c", (char)drive + 'A' - 1); #else - _snprintf(buf, len, "Drive %c", (char)drive + 'A' - 1); + snprintf(buf, len, "Drive %c", (char)drive + 'A' - 1); #endif } @@ -464,7 +460,7 @@ { time_t ltime; struct tm *tm; - char buffer[200], timebuf[200]; + char buffer[250], timebuf[200]; #ifdef __OS2__ const unsigned fea2listsize = 6000; char *pData; @@ -478,9 +474,9 @@ tm = localtime(<ime); - strftime(timebuf, 200, "%c", tm); + strftime(timebuf, sizeof(timebuf), "%c", tm); - sprintf(buffer, "%s %s", url, timebuf); + snprintf(buffer, sizeof(buffer), "%s %s", url, timebuf); #ifdef __OS2__ logfile = logfile;