diff options
author | Patrick Griffis <tingping@tingping.se> | 2016-04-26 12:05:57 -0400 |
---|---|---|
committer | Patrick Griffis <tingping@tingping.se> | 2016-04-26 12:06:28 -0400 |
commit | 5b097f560d54abedd4ca7597c627c7e017c19209 (patch) | |
tree | 96865d3f6d674497c2a4a749f14fc000904027f0 /src/common/text.c | |
parent | f06a38c384315f9bfcfe4905882486cc710439eb (diff) |
More minor scrollback loading improvements
Diffstat (limited to 'src/common/text.c')
-rw-r--r-- | src/common/text.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/common/text.c b/src/common/text.c index 2f20d171..06f72cfb 100644 --- a/src/common/text.c +++ b/src/common/text.c @@ -222,7 +222,7 @@ scrollback_load (session *sess) GDataInputStream *istream; gchar *buf, *text; gint lines = 0; - time_t stamp; + time_t stamp = 0; if (sess->text_scrollback == SET_DEFAULT) { @@ -272,12 +272,19 @@ scrollback_load (session *sess) * Some don't even have a timestamp * Some don't have any text at all */ - if (buf[0] == 'T') + if (buf[0] == 'T' && buf[1] == ' ') { if (sizeof (time_t) == 4) - stamp = g_ascii_strtoull (buf + 2, NULL, 10); + stamp = strtoul (buf + 2, NULL, 10); else stamp = g_ascii_strtoull (buf + 2, NULL, 10); /* in case time_t is 64 bits */ + + if (G_UNLIKELY(stamp == 0)) + { + g_warning ("Invalid timestamp in scrollback file"); + continue; + } + text = strchr (buf + 3, ' '); if (text && text[1]) { @@ -314,7 +321,7 @@ scrollback_load (session *sess) /* If its only an encoding error it may be specific to the line */ if (g_error_matches (err, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE)) { - g_warning ("Invalid utf8 in scrollback file\n"); + g_warning ("Invalid utf8 in scrollback file"); g_clear_error (&err); continue; } @@ -336,8 +343,7 @@ scrollback_load (session *sess) if (lines) { text = ctime (&stamp); - text[24] = 0; /* get rid of the \n */ - buf = g_strdup_printf ("\n*\t%s %s\n\n", _("Loaded log from"), text); + buf = g_strdup_printf ("\n*\t%s %s\n", _("Loaded log from"), text); fe_print_text (sess, buf, 0, TRUE); g_free (buf); /*EMIT_SIGNAL (XP_TE_GENMSG, sess, "*", buf, NULL, NULL, NULL, 0);*/ |