From nobody@FreeBSD.org  Sat Oct 19 02:15:42 2013
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1])
	(using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by hub.freebsd.org (Postfix) with ESMTP id 6AE223BB
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 19 Oct 2013 02:15:42 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from oldred.freebsd.org (oldred.freebsd.org [8.8.178.121])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.freebsd.org (Postfix) with ESMTPS id 577642D12
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 19 Oct 2013 02:15:42 +0000 (UTC)
Received: from oldred.freebsd.org ([127.0.1.6])
	by oldred.freebsd.org (8.14.5/8.14.7) with ESMTP id r9J2Ffh5050925
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 19 Oct 2013 02:15:41 GMT
	(envelope-from nobody@oldred.freebsd.org)
Received: (from nobody@localhost)
	by oldred.freebsd.org (8.14.5/8.14.5/Submit) id r9J2Ffan050921;
	Sat, 19 Oct 2013 02:15:41 GMT
	(envelope-from nobody)
Message-Id: <201310190215.r9J2Ffan050921@oldred.freebsd.org>
Date: Sat, 19 Oct 2013 02:15:41 GMT
From: Anthony Donnelly <Amzo@archbsd.net>
To: freebsd-gnats-submit@FreeBSD.org
Subject: mtree generation issue with libarchive
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         183093
>Category:       kern
>Synopsis:       [libarchive] [patch] mtree generation issue with libarchive
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Oct 19 02:20:00 UTC 2013
>Closed-Date:    
>Last-Modified:  Sun Oct 20 23:06:42 UTC 2013
>Originator:     Anthony Donnelly
>Release:        FreeBSD 10-stable
>Organization:
>Environment:
FreeBSD Bahamut 10.0-ALPHA6 FreeBSD 10.0-ALPHA6 #0 59c3f5e(stable/10)-dirty: Fri Oct 11 04:37:22 BST 2013     root@Bahamut:/usr/home/amzo/abs/core/FreeBSD/src/obj/amd64.amd64/usr/home/amzo/abs/core/FreeBSD/src/freebsd/sys/ARCHBSD_x86_64  x86_64

>Description:
libarchive that is currently part of base, reports ENOMEM on mtree generation.

The issue is also present here: 

http://code.google.com/p/libarchive/issues/detail?id=301

Which was reported fixed in 3.1.1 but the issue is still present in libarchive in world in 10-stable.
>How-To-Repeat:
Follow the Steps here: http://code.google.com/p/libarchive/issues/detail?id=301#c4
>Fix:
--- contrib/libarchive/libarchive/archive_write_set_format_mtree.c	2013-10-18 15:55:49.918078350 +0100
+++ contrib/libarchive/libarchive/archive_write_set_format_mtree.c.new	2013-10-18 15:57:24.640074710 +0100
@@ -1857,7 +1857,7 @@
 
 	/* Make a basename from dirname and slash */
 	*slash  = '\0';
-	file->parentdir.length = slash - dirname;
+	file->parentdir.length = slash - file->parentdir.s;
 	archive_strcpy(&(file->basename),  slash + 1);
 	return (ret);
 }

>Release-Note:
>Audit-Trail:
>Unformatted:
