Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 22 Jul 2008 14:43:51 GMT
From:      Gleb Kurtsou <gk@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 145613 for review
Message-ID:  <200807221443.m6MEhpuf055152@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=145613

Change 145613 by gk@gk_h1 on 2008/07/22 14:43:20

	more strictly parse table file entries (according to man page).
	enforce one entry per line. allow spaces on lines (for ether addresses)

Affected files ...

.. //depot/projects/soc2008/gk_l2filter/sbin-pfctl/pfctl_radix.c#2 edit

Differences ...

==== //depot/projects/soc2008/gk_l2filter/sbin-pfctl/pfctl_radix.c#2 (text+ko) ====

@@ -607,12 +607,20 @@
 	do {
 		if (i < BUF_SIZE)
 			buf[i++] = next_ch;
-		next_ch = fgetc(fp);
-	} while (!feof(fp) && !isspace(next_ch));
+		/* leave only 1 space */
+		if (isspace(next_ch)) {
+			while (isspace(next_ch) && next_ch != '\n' && !feof(fp))
+				next_ch = fgetc(fp);
+		} else {
+			next_ch = fgetc(fp);
+		}
+	} while (!feof(fp) && next_ch != '\n');
 	if (i >= BUF_SIZE) {
 		errno = EINVAL;
 		return (-1);
 	}
+	if (i > 0 && isspace(buf[i-1]))
+		i--;
 	buf[i] = '\0';
 	return (1);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200807221443.m6MEhpuf055152>