From patchwork Tue May 17 15:42:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jo-Philipp Wich X-Patchwork-Id: 623178 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3r8M8j1f4Gz9t6F for ; Wed, 18 May 2016 01:44:53 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1b2h9n-00075z-8k; Tue, 17 May 2016 15:43:39 +0000 Received: from mxout01.bytecamp.net ([212.204.60.217]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1b2h9l-0006vw-G4 for lede-dev@lists.infradead.org; Tue, 17 May 2016 15:43:38 +0000 Received: by mxout01.bytecamp.net (Postfix, from userid 1001) id 5CA3E30FE45; Tue, 17 May 2016 17:42:30 +0200 (CEST) Received: from mail.bytecamp.net (mailstore.bytecamp.net [212.204.60.20]) by mxout01.bytecamp.net (Postfix) with ESMTP id 1456530FE11 for ; Tue, 17 May 2016 17:42:29 +0200 (CEST) Received: (qmail 24888 invoked by uid 89); 17 May 2016 17:42:29 +0200 Received: from unknown (HELO localhost.localdomain) (jo%wwsnet.net@213.61.250.148) by mail.bytecamp.net with AES128-SHA encrypted SMTP; 17 May 2016 17:42:29 +0200 From: Jo-Philipp Wich To: lede-dev@lists.infradead.org Date: Tue, 17 May 2016 17:42:11 +0200 Message-Id: <789771690482fcd43a5369d1115f236b6b1c97f2.1463499516.git.jo@mein.io> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160517_084337_744462_3ED5B6D2 X-CRM114-Status: UNSURE ( 7.79 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [212.204.60.217 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Subject: [LEDE-DEV] [PATCH 2/2] utils: use O_PATH when opening /dev X-BeenThere: lede-dev@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jo-Philipp Wich , john@phrozen.org MIME-Version: 1.0 Sender: "Lede-dev" Errors-To: lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Use the O_PATH and O_DIRECTORY flags when opening the "/dev" path for the subsequent openat() call to ensure that it is indeed a directory. Signed-off-by: Jo-Philipp Wich --- utils/utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/utils.c b/utils/utils.c index ebf5447..e2e3396 100644 --- a/utils/utils.c +++ b/utils/utils.c @@ -165,7 +165,7 @@ int patch_fd(const char *device, int fd, int flags) device = "/dev/null"; if (*device != '/') { - dfd = open("/dev", O_RDONLY); + dfd = open("/dev", O_PATH|O_DIRECTORY); if (dfd < 0) return -1;