]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Fix few bugs in archive_cmdline.
authorMichihiro NAKAJIMA <ggcueroad@gmail.com>
Thu, 11 Oct 2012 10:51:08 +0000 (19:51 +0900)
committerMichihiro NAKAJIMA <ggcueroad@gmail.com>
Thu, 11 Oct 2012 10:51:08 +0000 (19:51 +0900)
libarchive/archive_cmdline.c

index 5129ab3d666cda3d4783b4d282716cfef7131997..7d3bac53bb5c5e6bf3520e6c07421df050241d16 100644 (file)
@@ -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));
 }
 
 /*