diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-10-07 20:43:45 -0400 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-10-07 20:43:45 -0400 |
commit | 272f85bb244462acf09cb4235a9b176f68f75a5f (patch) | |
tree | 1201c9bf074ed085fc164ddb649d464b7ca487c0 | |
parent | f61ee20ba356ecfc4c5b247f548f52d588179c94 (diff) | |
download | subsurface-272f85bb244462acf09cb4235a9b176f68f75a5f.tar.gz |
Fix silly crash
Who the heck uses strcpy?
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | dive.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -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 |