netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: arturo.borrero.glez@gmail.com
Subject: [PATCH nft 2/3] scanner: don't fall back on current directory if include is not found
Date: Tue,  9 Aug 2016 11:29:41 +0200	[thread overview]
Message-ID: <1470734982-10298-2-git-send-email-pablo@netfilter.org> (raw)
In-Reply-To: <1470734982-10298-1-git-send-email-pablo@netfilter.org>

This resolves an ambiguity if the same file name is used both under
sysconfdir and the current working directory.

Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1040
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 src/scanner.l | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/src/scanner.l b/src/scanner.l
index 6f1a551..cb2ea32 100644
--- a/src/scanner.l
+++ b/src/scanner.l
@@ -639,16 +639,15 @@ int scanner_include_file(void *scanner, const char *filename,
 			if (f != NULL)
 				break;
 		}
-	}
-	if (f == NULL) {
+	} else {
 		f = fopen(filename, "r");
-		if (f == NULL) {
-			erec = error(loc, "Could not open file \"%s\": %s\n",
-				     filename, strerror(errno));
-			goto err;
-		}
 		name = filename;
 	}
+	if (f == NULL) {
+		erec = error(loc, "Could not open file \"%s\": %s\n",
+			     filename, strerror(errno));
+		goto err;
+	}
 
 	erec = scanner_push_file(scanner, name, f, loc);
 	if (erec != NULL)
-- 
2.1.4


  reply	other threads:[~2016-08-09  9:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-09  9:29 [PATCH nft 1/3] scanner: honor absolute and relative paths via include file Pablo Neira Ayuso
2016-08-09  9:29 ` Pablo Neira Ayuso [this message]
2016-08-09  9:29 ` [PATCH nft 3/3] scanner: don't break line on include error message Pablo Neira Ayuso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1470734982-10298-2-git-send-email-pablo@netfilter.org \
    --to=pablo@netfilter.org \
    --cc=arturo.borrero.glez@gmail.com \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).