1 Description: Fix parsing of lines longer than 2047 characters
2 If a line in /etc/hosts.{allow,deny} is longer than BUFLEN-1 (2047)
3 characters then len will be set to 1 at the end of the xgets() loop.
5 At the next iteration, fgets will be passed a buffer of length 1, so it
6 will only be able to read an empty string (the buffer must always have
7 space for the trailing NUL).
9 strlen(3) on the empty string will return 0, so len will not be modified
10 anymore and the last step will repeat forever.
13 perl -e 'print "#sshd: " . ("127.0.0.1, " x 210) . "\n"' > hosts.deny
14 tcpdmatch -d test localhost
15 Author: Marco d'Itri <md@linux.it>
16 Bug-Debian: http://bugs.debian.org/596261
20 @@ -45,6 +45,8 @@ FILE *fp;
28 return (ptr > start ? start : 0);
31 @@ -165,7 +165,9 @@ struct request_info *request;
32 while (match == NO && xgets(sv_list, sizeof(sv_list), fp) != 0) {
33 if (sv_list[strlen(sv_list) - 1] != '\n') {
34 tcpd_warn("missing newline or line too long");
36 + tcpd_warn("all the subsequent rules will be ignored");
40 if (sv_list[0] == '#' || sv_list[strspn(sv_list, " \t\r\n")] == 0)