summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColomban Wendling <[email protected]>2024-01-23 23:08:04 +0100
committerraveit65 <[email protected]>2024-01-31 14:08:57 +0100
commitd39e5c2ef97352e4385b9cec69032bfc0124050f (patch)
tree539bb38d401768670ba763d515bd5d008b507bf8
parent01a64cddcd20b8b6647962e1336a3bb608d39a02 (diff)
downloadengrampa-d39e5c2ef97352e4385b9cec69032bfc0124050f.tar.bz2
engrampa-d39e5c2ef97352e4385b9cec69032bfc0124050f.tar.xz
zip: Fix crashes on buggy zip output
Fix crash if the `zip` command emits a line starting with one of 'd?-' yet having less than 8 fields in it, or if the date field is malformed.
-rw-r--r--src/fr-command-zip.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/fr-command-zip.c b/src/fr-command-zip.c
index cd191bd..acdc5ad 100644
--- a/src/fr-command-zip.c
+++ b/src/fr-command-zip.c
@@ -59,6 +59,10 @@ mktime_from_string (char *datetime_s)
char *min;
char *sec;
+ /* expected YYYYMMDD.HHMMSS */
+ if (strlen (datetime_s) < 15)
+ return mktime (&tm);
+
tm.tm_isdst = -1;
/* date */
@@ -124,9 +128,14 @@ list__process_line (char *line,
/**/
+ fields = split_line (line, 7);
+ if (g_strv_length (fields) < 7) {
+ g_strfreev (fields);
+ return;
+ }
+
fdata = file_data_new ();
- fields = split_line (line, 7);
fdata->size = g_ascii_strtoull (fields[3], NULL, 10);
fdata->modified = mktime_from_string (fields[6]);
fdata->encrypted = (*fields[4] == 'B') || (*fields[4] == 'T');
@@ -135,6 +144,8 @@ list__process_line (char *line,
/* Full path */
name_field = get_last_field (line, 8);
+ if (name_field == NULL)
+ name_field = "";
if (*name_field == '/') {
fdata->full_path = g_strdup (name_field);