aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-10-07 20:43:45 -0400
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-10-07 20:43:45 -0400
commit272f85bb244462acf09cb4235a9b176f68f75a5f (patch)
tree1201c9bf074ed085fc164ddb649d464b7ca487c0
parentf61ee20ba356ecfc4c5b247f548f52d588179c94 (diff)
downloadsubsurface-272f85bb244462acf09cb4235a9b176f68f75a5f.tar.gz
Fix silly crash
Who the heck uses strcpy? Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-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