Date: Sat, 8 Jul 2000 22:32:24 -0700 (PDT) From: spock@techfour.net To: freebsd-gnats-submit@FreeBSD.org Subject: misc/19793: [PATCH] ipfilter - improve line reading Message-ID: <20000709053224.6C4AE37B6EB@hub.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 19793
>Category: misc
>Synopsis: [PATCH] ipfilter - improve line reading
>Confidential: no
>Severity: non-critical
>Priority: high
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Sat Jul 08 22:40:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator: Mike Heffner
>Release: FreeBSD 5.0-CURRENT
>Organization:
>Environment:
FreeBSD 5.0-CURRENT #1: Tue Jul 4 22:23:05 EDT 2000 i386
>Description:
ipfilter does not support:
1) no-newline-at-end-of-file case when reading a rulelist from a file.
2) line continuation with "\", although it says it is supported in a code comment.
>How-To-Repeat:
Ipfilter should be able to read lines like:
pass in from\
any to any port = 23
block in all<EOF>
>Fix:
A patch similar to this should fix both problems:
--- /tmp/ipf.c Wed Jul 5 00:20:50 2000
+++ contrib/ipfilter/ipf.c Sun Jul 9 01:02:35 2000
@@ -347,12 +347,20 @@
if (fgets(p, s, file) == NULL)
return (NULL);
len = strlen(p);
+ if (p[len - 1] != '\n') {
+ p[len] = '\0';
+ break;
+ }
p[len - 1] = '\0';
- if (p[len - 1] != '\\')
+ if (len < 2 || p[len - 2] != '\\')
break;
- size -= len;
+ else {
+ /* Convert '\\' to a space so words don't run together */
+ p[len - 2] = ' ';
+ len--;
+ }
}
- } while (*str == '\0' || *str == '\n');
+ } while (*str == '\0');
return (str);
}
>Release-Note:
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000709053224.6C4AE37B6EB>
