summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dive.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/dive.c b/dive.c
index 1efdedef4..ea771f94e 100644
--- a/dive.c
+++ b/dive.c
@@ -2486,9 +2486,11 @@ void set_save_userid_local(short value)
void set_userid(char *rUserId)
{
- prefs.userid = (char *) malloc(MAX_USERID_SIZE);
- if (prefs.userid && rUserId)
- strcpy(prefs.userid, rUserId);
+ prefs.userid = (char *) malloc(MAX_USERID_SIZE + 1);
+ if (prefs.userid && rUserId) {
+ strncpy(prefs.userid, rUserId, MAX_USERID_SIZE);
+ prefs.userid[MAX_USERID_SIZE] = 0;
+ }
}
#undef MAX_USERID_SIZE