summaryrefslogtreecommitdiff
path: root/greeter/Login.c
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu@cvs.openbsd.org>2018-07-10 14:44:35 +0000
committerMatthieu Herrb <matthieu@herrb.eu>2020-07-14 15:52:40 +0200
commit73935283dea4c05c18e2ee2d3606e450d052c60c (patch)
treeb031ab44595042c6d71811ac432cdf4cf827a37d /greeter/Login.c
parent82550d3e45c4df951eb7fc669e6b2d55037cc629 (diff)
Get rid of strcpy and strncpy (they were all looking safe though)
Diffstat (limited to 'greeter/Login.c')
-rw-r--r--greeter/Login.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/greeter/Login.c b/greeter/Login.c
index 5692071..252ea94 100644
--- a/greeter/Login.c
+++ b/greeter/Login.c
@@ -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);
}
}