From owner-svn-src-all@FreeBSD.ORG Sat Mar 7 01:17:14 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 041EA106566B; Sat, 7 Mar 2009 01:17:14 +0000 (UTC) (envelope-from kientzle@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CC5958FC12; Sat, 7 Mar 2009 01:17:13 +0000 (UTC) (envelope-from kientzle@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n271HDAH034059; Sat, 7 Mar 2009 01:17:13 GMT (envelope-from kientzle@svn.freebsd.org) Received: (from kientzle@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n271HDLr034058; Sat, 7 Mar 2009 01:17:13 GMT (envelope-from kientzle@svn.freebsd.org) Message-Id: <200903070117.n271HDLr034058@svn.freebsd.org> From: Tim Kientzle Date: Sat, 7 Mar 2009 01:17:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r189469 - head/lib/libarchive X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Mar 2009 01:17:14 -0000 Author: kientzle Date: Sat Mar 7 01:17:13 2009 New Revision: 189469 URL: http://svn.freebsd.org/changeset/base/189469 Log: Merge r564,r566 from libarchive.googlecode.com: Fix segfault when specifying an option and the current format doesn't have an options handler. Modified: head/lib/libarchive/archive_read.c Modified: head/lib/libarchive/archive_read.c ============================================================================== --- head/lib/libarchive/archive_read.c Sat Mar 7 01:12:01 2009 (r189468) +++ head/lib/libarchive/archive_read.c Sat Mar 7 01:17:13 2009 (r189469) @@ -115,24 +115,30 @@ int archive_read_set_format_options(struct archive *_a, const char *s) { struct archive_read *a; + struct archive_format_descriptor *format; char key[64], val[64]; + size_t i; int len, r; a = (struct archive_read *)_a; - if (a->format == NULL || a->format->options == NULL || - a->format->name == NULL) - /* This format does not support option. */ - return (ARCHIVE_OK); - - while ((len = __archive_parse_options(s, a->format->name, - sizeof(key), key, sizeof(val), val)) > 0) { - if (val[0] == '\0') - r = a->format->options(a, key, NULL); - else - r = a->format->options(a, key, val); - if (r == ARCHIVE_FATAL) - return (r); - s += len; + len = 0; + for (i = 0; i < sizeof(a->formats)/sizeof(a->formats[0]); i++) { + format = &a->formats[i]; + if (format == NULL || format->options == NULL || + format->name == NULL) + /* This format does not support option. */ + continue; + + while ((len = __archive_parse_options(s, format->name, + sizeof(key), key, sizeof(val), val)) > 0) { + if (val[0] == '\0') + r = format->options(a, key, NULL); + else + r = format->options(a, key, val); + if (r == ARCHIVE_FATAL) + return (r); + s += len; + } } if (len < 0) { archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, @@ -159,6 +165,8 @@ archive_read_set_filter_options(struct a len = 0; for (filter = a->filter; filter != NULL; filter = filter->upstream) { bidder = filter->bidder; + if (bidder == NULL) + continue; if (bidder->options == NULL) /* This bidder does not support option */ continue;