changeset 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 197f9463efa8
children 433b7c772ff0
files dwcompat.c
diffstat 1 files changed, 4 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- 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(&ltime);
 
-	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;