naccyde / rpms / iproute

Forked from rpms/iproute 5 months ago
Clone

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

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