Get rid of strcpy and strncpy (they were all looking safe though)
This commit is contained in:
parent
1b4f7ecea8
commit
a08190694c
@ -763,7 +763,7 @@ SetPrompt (Widget ctx, int promptNum, const char *message,
|
||||
return -1;
|
||||
}
|
||||
|
||||
strncpy(prompt, message, messageLen);
|
||||
strlcpy(prompt, message, messageLen);
|
||||
|
||||
/* Make sure text prompts have at least two spaces at end */
|
||||
e = messageLen;
|
||||
@ -838,12 +838,10 @@ SetValue(Widget ctx, int promptNum, char *value)
|
||||
if (VALUE_TEXT(w, promptNum) == NULL)
|
||||
return -1;
|
||||
|
||||
if (value == NULL) {
|
||||
if (value == NULL)
|
||||
bzero(VALUE_TEXT(w, promptNum), VALUE_TEXT_MAX(w, promptNum));
|
||||
} else {
|
||||
strncpy(VALUE_TEXT(w, promptNum), value, VALUE_TEXT_MAX(w, promptNum));
|
||||
VALUE_TEXT(w, promptNum)[VALUE_TEXT_MAX(w, promptNum)] = '\0';
|
||||
}
|
||||
else
|
||||
strlcpy(VALUE_TEXT(w, promptNum), value, VALUE_TEXT_MAX(w, promptNum));
|
||||
|
||||
VALUE_SHOW_START(w, promptNum) = 0;
|
||||
VALUE_SHOW_END(w, promptNum) = 0;
|
||||
@ -885,8 +883,9 @@ realizeDeleteChar (LoginWidget ctx)
|
||||
} else {
|
||||
EraseValue (ctx, redrawFrom, promptNum);
|
||||
}
|
||||
strcpy(VALUE_TEXT(ctx, promptNum) + PROMPT_CURSOR(ctx, promptNum),
|
||||
VALUE_TEXT(ctx, promptNum) + PROMPT_CURSOR(ctx, promptNum) + 1);
|
||||
strlcpy(VALUE_TEXT(ctx, promptNum) + PROMPT_CURSOR(ctx, promptNum),
|
||||
VALUE_TEXT(ctx, promptNum) + PROMPT_CURSOR(ctx, promptNum) + 1,
|
||||
VALUE_TEXT_MAX(ctx, promptNum));
|
||||
DrawValue (ctx, redrawFrom, promptNum);
|
||||
}
|
||||
}
|
||||
|
@ -101,10 +101,8 @@ GreetDone (
|
||||
data->name, strlen (data->passwd));
|
||||
switch (status) {
|
||||
case NOTIFY_OK:
|
||||
strncpy (name, data->name, sizeof(name));
|
||||
name[sizeof(name)-1] = '\0';
|
||||
strncpy (password, data->passwd, sizeof(password));
|
||||
password[sizeof(password)-1] = '\0';
|
||||
strlcpy (name, data->name, sizeof(name));
|
||||
strlcpy (password, data->passwd, sizeof(password));
|
||||
code = 0;
|
||||
done = 1;
|
||||
break;
|
||||
|
@ -724,8 +724,7 @@ setAuthNumber (Xauth *auth, char *name)
|
||||
auth->number_length = strlen (colon);
|
||||
number = malloc (auth->number_length + 1);
|
||||
if (number) {
|
||||
strncpy (number, colon, auth->number_length);
|
||||
number[auth->number_length] = '\0';
|
||||
strlcpy (number, colon, auth->number_length);
|
||||
} else {
|
||||
LogOutOfMem ("setAuthNumber");
|
||||
auth->number_length = 0;
|
||||
|
@ -89,8 +89,7 @@ splitIntoWords (char *s)
|
||||
freeFileArgs (args);
|
||||
return NULL;
|
||||
}
|
||||
strncpy (args[nargs], wordStart, s - wordStart);
|
||||
args[nargs][s-wordStart] = '\0';
|
||||
strlcpy (args[nargs], wordStart, s - wordStart);
|
||||
++nargs;
|
||||
args[nargs] = NULL;
|
||||
}
|
||||
|
@ -260,18 +260,15 @@ GetResource (
|
||||
LogOutOfMem ("GetResource");
|
||||
return;
|
||||
}
|
||||
strncpy (new_string, string, len);
|
||||
new_string[len] = '\0';
|
||||
strlcpy (new_string, string, len);
|
||||
*(valuep) = new_string;
|
||||
break;
|
||||
case DM_INT:
|
||||
strncpy (str_buf, string, sizeof (str_buf));
|
||||
str_buf[sizeof (str_buf)-1] = '\0';
|
||||
strlcpy (str_buf, string, sizeof (str_buf));
|
||||
*((int *) valuep) = atoi (str_buf);
|
||||
break;
|
||||
case DM_BOOL:
|
||||
strncpy (str_buf, string, sizeof (str_buf));
|
||||
str_buf[sizeof (str_buf)-1] = '\0';
|
||||
strlcpy (str_buf, string, sizeof (str_buf));
|
||||
XmuCopyISOLatin1Lowered (str_buf, str_buf);
|
||||
if (!strcmp (str_buf, "true") ||
|
||||
!strcmp (str_buf, "on") ||
|
||||
|
@ -136,8 +136,7 @@ putEnv(const char *string, char **env)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
strncpy(n, string,nl + 1);
|
||||
n[nl] = 0;
|
||||
strlcpy(n, string,nl + 1);
|
||||
|
||||
env = setEnv(env,n,v);
|
||||
free(n);
|
||||
@ -193,8 +192,8 @@ parseArgs (char **argv, const char *string)
|
||||
} else {
|
||||
argv = newargv;
|
||||
}
|
||||
argv[i] = strncpy (save, word, string-word);
|
||||
argv[i][string-word] = '\0';
|
||||
strlcpy (save, word, string-word);
|
||||
argv[i] = save;
|
||||
i++;
|
||||
}
|
||||
if (!*string)
|
||||
|
Loading…
Reference in New Issue
Block a user