diff options
author | Pascal Quantin <pascal.quantin@gmail.com> | 2013-07-19 08:04:58 +0000 |
---|---|---|
committer | Pascal Quantin <pascal.quantin@gmail.com> | 2013-07-19 08:04:58 +0000 |
commit | 57aebcf7764e6b3e54ba43a4ed4a30fa92c5cdb2 (patch) | |
tree | 4ea9e78a7c08da71a04f2afafe74260109c0d9bd /epan/prefs.c | |
parent | 23d9a348a1fea58e1e0ab160703401ca8f990f19 (diff) |
From Cal Turney via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8942 :
Fix segmentation fault when reading pref file
svn path=/trunk/; revision=50737
Diffstat (limited to 'epan/prefs.c')
-rw-r--r-- | epan/prefs.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/epan/prefs.c b/epan/prefs.c index 22e2546949..3cb90f4cd2 100644 --- a/epan/prefs.c +++ b/epan/prefs.c @@ -3066,24 +3066,20 @@ read_prefs_file(const char *pf_path, FILE *pf, cur_val = g_string_new(""); cur_var = g_string_new(""); -#if 0 /* Try to read in the profile name in the first line of the preferences file. */ got_c = getc(pf); if(got_c) { - GString *firstl = (GString *)pf; + char firstl[100]; - if (strncmp(firstl->str, " Configuration file for ", 24) == 0) { - gchar *eol; - gsize len; - - firstl->str += 24; - eol = strchr((char *) firstl->str, '\n'); - len = eol - firstl->str - 1; - prefs.saved_at_version = g_strndup((const gchar *)firstl->str, len); + if (fgets(firstl, 100, pf) != NULL) { + if (strncmp((const char *)firstl, " Configuration file for ", 24) == 0) { + const gchar *ver = (gchar *)&firstl[24]; + /* Eliminate the period and LF the end of the string */ + prefs.saved_at_version = g_strndup(ver, strlen(ver) - 2); + } } } rewind(pf); -#endif while ((got_c = getc(pf)) != EOF) { if (got_c == '\n') { |