pkgsrc-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

pkg/52450: archivers/bsdtar libc assertion (with patch)



>Number:         52450
>Category:       pkg
>Synopsis:       archivers/bsdtar libc assertion (with patch)
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Aug 01 01:10:00 +0000 2017
>Originator:     David A. Holland
>Release:        NetBSD 7.99.65 (pkgsrc 20170710)
>Organization:
>Environment:
System: NetBSD macaran 7.99.65 NetBSD 7.99.65 (MACARAN) #41: Thu Mar 9 19:33:59 EST 2017 dholland@macaran:/usr/src/sys/arch/amd64/compile/MACARAN amd64
Architecture: x86_64
Machine: amd64
>Description:

Running bsdtar on some archives causes libc to spam syslogd with an
assertion message:

Jul 31 20:42:32 macaran bsdtar: assertion "s != NULL" failed: file "/usr/src/lib/libc/string/wmemmove.c", line 45, function "wmemmove"
Jul 31 20:42:51 macaran syslogd[207]: last message repeated 1023 times

maya@ found an archive that repeats the problem reliably (usually I
see it only during pkgsrc builds and it's never clear what exactly
triggers it) so here's a patch that fixes the problem.

>How-To-Repeat:

bsdtar -xvzf ...

>Fix:

Since bsdtar is actually libarchive and Joerg routinely rejects fixes to libarchive for unclear reasons, a (tested) patch:

   ------
$NetBSD$

Avoid undefined behavior that causes NetBSD's libc to syslog a warning.

--- libarchive/archive_string.c~	2017-08-01 00:43:27.172009807 +0000
+++ libarchive/archive_string.c
@@ -61,6 +61,7 @@ __FBSDID("$FreeBSD: head/lib/libarchive/
 #include <windows.h>
 #include <locale.h>
 #endif
+#include <assert.h>
 
 #include "archive_endian.h"
 #include "archive_private.h"
@@ -213,7 +214,11 @@ archive_wstring_append(struct archive_ws
 {
 	if (archive_wstring_ensure(as, as->length + s + 1) == NULL)
 		return (NULL);
-	wmemmove(as->s + as->length, p, s);
+	if (p != NULL) {
+		wmemmove(as->s + as->length, p, s);
+	} else {
+		assert(s == 0);
+	}
 	as->length += s;
 	as->s[as->length] = 0;
 	return (as);

   ------



Home | Main Index | Thread Index | Old Index