Fix silly crash

Who the heck uses strcpy?

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2014-10-07 20:43:45 -04:00
parent f61ee20ba3
commit 272f85bb24

8
dive.c
View file

@ -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