summaryrefslogtreecommitdiffstats
path: root/dive.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-11-20 14:30:44 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-11-20 14:30:44 -0800
commit2f7a7f3e6ac3d741bebd9e31f63d0bcf3f237774 (patch)
tree93a1d87066c08e8dae788e7455a18d7fed040103 /dive.c
parent21675de534243a65fdd19e28be1145e5f0e2d294 (diff)
downloadsubsurface-2f7a7f3e6ac3d741bebd9e31f63d0bcf3f237774.tar.gz
Prevent garbage from being saved in the userid field
It seems that in some scenarios we end up with a string that isn't NUL terminated and that results in garbage being stored as userid. This patch is a little brute force but it fixes the problem even if a previous version os Subsurface ended up adding other text to the end of the userid. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'dive.c')
-rw-r--r--dive.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/dive.c b/dive.c
index 56c0de0ec..78ad25532 100644
--- a/dive.c
+++ b/dive.c
@@ -2720,6 +2720,8 @@ void set_save_userid_local(short value)
void set_userid(char *rUserId)
{
prefs.userid = strdup(rUserId);
+ if (strlen(prefs.userid) > 30)
+ prefs.userid[30]='\0';
}
int average_depth(struct diveplan *dive)