From 25169e1b2c467bcee6adb80d7070a968c3ab4c3f Mon Sep 17 00:00:00 2001 From: Michihiro NAKAJIMA Date: Thu, 11 Oct 2012 19:51:08 +0900 Subject: [PATCH] Fix few bugs in archive_cmdline. --- libarchive/archive_cmdline.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/libarchive/archive_cmdline.c b/libarchive/archive_cmdline.c index 5129ab3d6..7d3bac53b 100644 --- a/libarchive/archive_cmdline.c +++ b/libarchive/archive_cmdline.c @@ -46,14 +46,19 @@ extract_quotation(struct archive_string *as, const char *p) { const char *s; - for (s = p + 1; *s; s++) { + for (s = p + 1; *s;) { if (*s == '\\') { - if (s[1] != '\0') - archive_strappend_char(as, s[0]); + if (s[1] != '\0') { + archive_strappend_char(as, s[1]); + s += 2; + } else + s++; } else if (*s == '"') break; - else + else { archive_strappend_char(as, s[0]); + s++; + } } if (*s != '"') return (ARCHIVE_FAILED);/* Invalid sequence. */ @@ -197,7 +202,7 @@ struct archive_cmdline * __archive_cmdline_allocate(void) { return (struct archive_cmdline *) - calloc(1, sizeof(struct archive_cmdline *)); + calloc(1, sizeof(struct archive_cmdline)); } /* -- 2.47.2