dtlogin: Two additional coverity fixes
authorPeter Howkins <flibble@users.sf.net>
Tue, 24 Apr 2018 02:57:35 +0000 (03:57 +0100)
committerPeter Howkins <flibble@users.sf.net>
Tue, 24 Apr 2018 02:57:35 +0000 (03:57 +0100)
cde/programs/dtlogin/account.c
cde/programs/dtlogin/vgmain.c

index c9ff601a015b79d58c43b0e73705540dec294395..cd33b637fa738f0c8c0f496192726b8ea05515d9 100644 (file)
@@ -243,10 +243,10 @@ Account( struct display *d, char *user, char *line, pid_t pid,
              close(fd);
         }
        else
-             strncpy(u->ut_line, line, sizeof(u->ut_line));
+             snprintf(u->ut_line, sizeof(u->ut_line), "%s", line);
             
 #else
-             strncpy(u->ut_line, line, sizeof(u->ut_line));
+             snprintf(u->ut_line, sizeof(u->ut_line), "%s", line);
 #endif
     }
     if (pid ) u->ut_pid = pid;
index 1688110d723767affc2903168b0c73f17ca81be1..15cea36cb67a2fad8bcc7557d3edc642b09e913e 100644 (file)
@@ -940,9 +940,9 @@ char            *temp_p;
               * remove trailing spaces 
               */
               if (strchr(startup_value.addr, ' ')) 
-                  strcpy(temp, strtok(startup_value.addr," "));
+                  snprintf(temp, sizeof(temp), "%s", strtok(startup_value.addr, " "));
                else
-                  strcpy(temp, startup_value.addr);
+                  snprintf(temp, sizeof(temp), "%s", startup_value.addr);
 
               if (default_is_custom_dt)
                 if (strcmp(session, temp) == 0)    {
@@ -1207,7 +1207,7 @@ MakeDialog( DialogType dtype )
     FILE       *fp, *fopen();
     char       buffer[128];
 
-    Widget     w, text;
+    Widget     w = NULL, text;
     Dimension txt_width, txt_height;
     XmString   ok, cancel, nw, sv;
 
@@ -1401,7 +1401,9 @@ MakeDialog( DialogType dtype )
 
 
     XtSetArg(argt[0], XmNdialogStyle,  XmDIALOG_APPLICATION_MODAL      ); i++;
-    XtSetValues(w, argt, 1);
+    if(w) {
+        XtSetValues(w, argt, 1);
+    }
 
     XmStringFree(xmstr);
     XmStringFree(ok);