From patchwork Wed Aug 24 14:19:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yann E. MORIN" X-Patchwork-Id: 662319 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3sK8Zp1yV3z9sxb for ; Thu, 25 Aug 2016 00:19:46 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=K9ZvW4Is; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id B9F848A7FC; Wed, 24 Aug 2016 14:19:41 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XtdpAIZTbvZT; Wed, 24 Aug 2016 14:19:39 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id 86FC58A440; Wed, 24 Aug 2016 14:19:39 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 7E44E1C2957 for ; Wed, 24 Aug 2016 14:19:38 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 79AE087364 for ; Wed, 24 Aug 2016 14:19:38 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YUSvLZOyZjRi for ; Wed, 24 Aug 2016 14:19:37 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by whitealder.osuosl.org (Postfix) with ESMTPS id 72D698BE14 for ; Wed, 24 Aug 2016 14:19:37 +0000 (UTC) Received: by mail-wm0-f66.google.com with SMTP id q128so2877128wma.1 for ; Wed, 24 Aug 2016 07:19:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id; bh=aJeglYslZiZIbKoZgFFF+rN7LWmCz7wIChM42BQTZOU=; b=K9ZvW4IsEz7h2+hBQOH5S4WBPfIv9qPp6Kmab/QvVABf/yNXrJRq/XKMr45jVXtdwx NingNyBidWlreTUYsBbw7IAWt2kuomv7ACntapzAk8YEksAHQVjor9K/6nOyleilLmhs OKA4dAYnG6uOLf89XnT8aINGBx3Bnwb1rhIvvrtZqhYU3NCOZ0OUlbwz4veJuGF3Pz0c g8M+pnpqJpiPFjQCQbyVt1K83IfX5Eg6W5jKfPalgCns9YGwQy5zqumEXCbUiBFlIibw +TZvV6ADRNGW+Ii2B0yJY8oxEOFpqeNZ8KofXN9xXQpo8s9g59haOd1vtKAI5/2KCTxq AnTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=aJeglYslZiZIbKoZgFFF+rN7LWmCz7wIChM42BQTZOU=; b=fQMIvXsmKg2q30ER/PSxTF9n8aakHNCYchjy2H66qPsvVTEpA5f90dUuTB+Yfqix5M 7PGJqohik92qpvfrL+dPrZVhKozHGCae8V/Zr9FVZ/Mh2sfghSU4k+6ngPrOJXTud8nc tJoVgG/r85KJVOFTu5NoL6VIXnqC0GHA6P3oxWvPgPSPJyRtbFe0FyuCPfdMFZS5LgL8 Ys5PpuJEtegPOjDemHU/iVy/tjHJhaUPJDBTNc4WAiViA3a2bV2yWGIKPnDd+NVtlC1m JPj8GtiNbyeaiWA66qMI1Y4KFiFRMAziAcodND1OP3U8+wjezVQltaq8RacCHQsycQ52 g6vw== X-Gm-Message-State: AE9vXwP6nLU2GC1/01tgCE57ncZXokbx88Zf+Wzu2qgOW7R4AGnS9Y8LJ3wb8CoBTNMNqA== X-Received: by 10.28.71.197 with SMTP id m66mr3479722wmi.26.1472048375865; Wed, 24 Aug 2016 07:19:35 -0700 (PDT) Received: from gourin.bzh.lan (ns304657.ip-46-105-103.eu. [46.105.103.66]) by smtp.gmail.com with ESMTPSA id p1sm10237510wjd.37.2016.08.24.07.19.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 24 Aug 2016 07:19:34 -0700 (PDT) From: "Yann E. MORIN" To: buildroot@buildroot.org Date: Wed, 24 Aug 2016 16:19:29 +0200 Message-Id: <1472048370-20408-1-git-send-email-yann.morin.1998@free.fr> X-Mailer: git-send-email 2.7.4 Cc: Thomas Petazzoni , "Yann E. MORIN" Subject: [Buildroot] [PATCH 1/2] toolchain/wrapper: display options leading to a paranoid failure X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" Current, we only display the path that causes the paranoid failure. This is sufficient, as we can fail only for -I and -L options, and it is thus easy to infer from the path, which option is the culprit. However, we're soon to add a new test for the -isystem option, and then when a failure occurs, we would not know whether it was because of -I or -isystem. Being able to differentiate both can be hugely useful to track down the root cause for the unsafe path. Add two new arguments to the check_unsafe_path() function: one with the current-or-previous argument, one to specify whether it has the path in it or not. Print that in the error message, instead of just the path. Signed-off-by: "Yann E. MORIN" Cc: Thomas Petazzoni Cc: Arnout Vandecappelle --- Changes v1 -> v2; - don't use a variadic function; use explicit argumetns (Arnout) - print it on a single line (Arnout) --- toolchain/toolchain-wrapper.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/toolchain/toolchain-wrapper.c b/toolchain/toolchain-wrapper.c index 887058f..edade43 100644 --- a/toolchain/toolchain-wrapper.c +++ b/toolchain/toolchain-wrapper.c @@ -80,8 +80,13 @@ static char *predef_args[] = { #endif }; -static void check_unsafe_path(const char *path, int paranoid) +static void check_unsafe_path(const char *arg, + const char *path, + int paranoid, + int arg_has_path) { + va_list ap; + int once; char **c; static char *unsafe_paths[] = { "/lib", "/usr/include", "/usr/lib", "/usr/local/include", "/usr/local/lib", NULL, @@ -89,9 +94,15 @@ static void check_unsafe_path(const char *path, int paranoid) for (c = unsafe_paths; *c != NULL; c++) { if (!strncmp(path, *c, strlen(*c))) { - fprintf(stderr, "%s: %s: unsafe header/library path used in cross-compilation: '%s'\n", + fprintf(stderr, + "%s: %s: " + "unsafe header/library path used in cross-compilation:" + " '%s%s%s'\n", program_invocation_short_name, - paranoid ? "ERROR" : "WARNING", path); + paranoid ? "ERROR" : "WARNING", + arg, + arg_has_path ? "" : "' '", + arg_has_path ? "" : path); if (paranoid) exit(1); continue; @@ -237,9 +248,9 @@ int main(int argc, char **argv) i++; if (i == argc) continue; - check_unsafe_path(argv[i], paranoid); + check_unsafe_path(argv[i-1], argv[i], paranoid, 0); } else { - check_unsafe_path(argv[i] + 2, paranoid); + check_unsafe_path(argv[i], argv[i] + 2, paranoid, 1); } }