dtcm/props.c: coverity CID 88573; unbounded src buf
authorJon Trulson <jon@radscan.com>
Sun, 1 Apr 2018 20:04:25 +0000 (14:04 -0600)
committerJon Trulson <jon@radscan.com>
Sun, 1 Apr 2018 20:04:25 +0000 (14:04 -0600)
cde/programs/dtcm/libDtCmP/props.c

index c935c5792383a85135817f331fce2d329fa08f10..d213cd31f8516686e9d99ae4aa45ed763ee815d9 100644 (file)
@@ -56,6 +56,7 @@ static char sccsid[] = "@(#)props.c 1.13 94/11/07 Copyr 1991 Sun Microsystems, I
 #include <nl_types.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include "props.h"
 #include "util.h"
 
@@ -435,12 +436,13 @@ save_props(Props *p)
        }
 
        if (ds_def)
-               sprintf(buf, "%s", ds_def);
+               snprintf(buf, MAXPATHLEN, "%s", ds_def);
        else
                if (getenv("HOME") != NULL)
-                       sprintf(buf, "%s%s", getenv("HOME"), DS_FILENAME);
+                    snprintf(buf, MAXPATHLEN, "%s%s",
+                             getenv("HOME"), DS_FILENAME);
                else
-                       sprintf(buf, "/%s", DS_FILENAME);
+                    snprintf(buf, MAXPATHLEN, "/%s", DS_FILENAME);
 
        return (save_resources(p->rdb, buf));
 }