Blame SOURCES/xfsprogs-4.15.0-xfs_db-fix-crash-when-field-list-selector-string-has.patch

89952e
From 945e47e2fcc5d1cec693122286da06d8ab829c52 Mon Sep 17 00:00:00 2001
89952e
From: "Darrick J. Wong" <darrick.wong@oracle.com>
89952e
Date: Thu, 4 Jan 2018 13:58:29 -0600
89952e
Subject: [PATCH] xfs_db: fix crash when field list selector string has
89952e
 trailing slash
89952e
89952e
If I run the following command:
89952e
89952e
xfs_db /dev/sdf -x -c 'agf 0' -c 'addr refcntroot' -c 'addr ptrs[1]\'
89952e
89952e
it errors out with "bad character in field \" and
89952e
then ftok_free crashes on an invalid free() because picking up the
89952e
previous token (the closing bracket) xrealloc'd the token array to be 5
89952e
elements long but never set the last element's tok pointer.
89952e
Consequently the ftok_free tries to free whatever garbage pointer is in
89952e
that last element and kaboom.
89952e
89952e
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
89952e
Reviewed-by: Eric Sandeen <sandeen@sandeen.net>
89952e
[sandeen: slightly clarify commit log]
89952e
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
89952e
---
89952e
 db/flist.c | 1 +
89952e
 1 file changed, 1 insertion(+)
89952e
89952e
Index: xfsprogs-4.5.0/db/flist.c
89952e
===================================================================
89952e
--- xfsprogs-4.5.0.orig/db/flist.c
89952e
+++ xfsprogs-4.5.0/db/flist.c
89952e
@@ -400,6 +400,7 @@ flist_split(
89952e
 		strncpy(a, s, l);
89952e
 		a[l] = '\0';
89952e
 		v = xrealloc(v, (nv + 2) * sizeof(*v));
89952e
+		v[nv + 1].tok = NULL;
89952e
 		v[nv].tok = a;
89952e
 		v[nv].tokty = t;
89952e
 		nv++;