naccyde / rpms / iproute

Forked from rpms/iproute 7 months ago
Clone

Blame SOURCES/0002-configure-fix-parsing-issue-on-libbpf_dir-option.patch

32391d
From a9cf0f0c57cf978ebe2abfd4c5a1b7df94f0a8ac Mon Sep 17 00:00:00 2001
32391d
Message-Id: <a9cf0f0c57cf978ebe2abfd4c5a1b7df94f0a8ac.1637678195.git.aclaudi@redhat.com>
32391d
In-Reply-To: <b30268eda844bdebbb8e5e4f5735e3b1bb666368.1637678195.git.aclaudi@redhat.com>
32391d
References: <b30268eda844bdebbb8e5e4f5735e3b1bb666368.1637678195.git.aclaudi@redhat.com>
32391d
From: Andrea Claudi <aclaudi@redhat.com>
32391d
Date: Tue, 23 Nov 2021 15:28:18 +0100
32391d
Subject: [PATCH] configure: fix parsing issue on libbpf_dir option
32391d
32391d
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2016061
32391d
Upstream Status: iproute2.git commit 48c379bc
32391d
32391d
commit 48c379bc2afd43b3246f68ed46475f5318b1218f
32391d
Author: Andrea Claudi <aclaudi@redhat.com>
32391d
Date:   Thu Oct 14 10:50:50 2021 +0200
32391d
32391d
    configure: fix parsing issue on libbpf_dir option
32391d
32391d
    configure is stuck in an endless loop if '--libbpf_dir' option is used
32391d
    without a value:
32391d
32391d
    $ ./configure --libbpf_dir
32391d
    ./configure: line 515: shift: 2: shift count out of range
32391d
    ./configure: line 515: shift: 2: shift count out of range
32391d
    [...]
32391d
32391d
    Fix it splitting 'shift 2' into two consecutive shifts, and making the
32391d
    second one conditional to the number of remaining arguments.
32391d
32391d
    A check is also provided after the while loop to verify the libbpf dir
32391d
    exists; also, as LIBBPF_DIR does not have a default value, configure bails
32391d
    out if the user does not specify a value after --libbpf_dir, thus avoiding
32391d
    to produce an erroneous configuration.
32391d
32391d
    Fixes: 7ae2585b865a ("configure: convert LIBBPF environment variables to command-line options")
32391d
    Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
32391d
    Acked-by: Phil Sutter <phil@nwl.cc>
32391d
    Signed-off-by: David Ahern <dsahern@kernel.org>
32391d
---
32391d
 configure | 10 +++++++---
32391d
 1 file changed, 7 insertions(+), 3 deletions(-)
32391d
32391d
diff --git a/configure b/configure
32391d
index ea9051ab..0f304206 100755
32391d
--- a/configure
32391d
+++ b/configure
32391d
@@ -486,7 +486,7 @@ usage()
32391d
 	cat <
32391d
 Usage: $0 [OPTIONS]
32391d
 	--include_dir <dir>	Path to iproute2 include dir
32391d
-	--libbpf_dir		Path to libbpf DESTDIR
32391d
+	--libbpf_dir <dir>	Path to libbpf DESTDIR
32391d
 	--libbpf_force		Enable/disable libbpf by force. Available options:
32391d
 				  on: require link against libbpf, quit config if no libbpf support
32391d
 				  off: disable libbpf probing
32391d
@@ -506,8 +506,9 @@ else
32391d
 				INCLUDE="$1"
32391d
 				[ "$#" -gt 0 ] && shift ;;
32391d
 			--libbpf_dir)
32391d
-				LIBBPF_DIR="$2"
32391d
-				shift 2 ;;
32391d
+				shift
32391d
+				LIBBPF_DIR="$1"
32391d
+				[ "$#" -gt 0 ] && shift ;;
32391d
 			--libbpf_force)
32391d
 				if [ "$2" != 'on' ] && [ "$2" != 'off' ]; then
32391d
 					usage 1
32391d
@@ -525,6 +526,9 @@ else
32391d
 fi
32391d
 
32391d
 [ -d "$INCLUDE" ] || usage 1
32391d
+if [ "${LIBBPF_DIR-unused}" != "unused" ]; then
32391d
+	[ -d "$LIBBPF_DIR" ] || usage 1
32391d
+fi
32391d
 
32391d
 echo "# Generated config based on" $INCLUDE >$CONFIG
32391d
 quiet_config >> $CONFIG
32391d
-- 
32391d
2.31.1
32391d