Working xgets with long lines
* previously, the long line led to infinite loop * now we get warning in /var/log/secure (and line is ignored)
This commit is contained in:
parent
17e25d186e
commit
cb31af92a4
|
@ -1,12 +1,49 @@
|
||||||
diff -up tcp_wrappers_7.6/misc.c.xgets tcp_wrappers_7.6/misc.c
|
commit 3ae65dc9a1c78c3088a08091f5d948fbbb8929af
|
||||||
--- tcp_wrappers_7.6/misc.c.xgets 2011-08-15 05:50:26.403091995 -0400
|
Author: Jakub Jelen <jjelen@redhat.com>
|
||||||
+++ tcp_wrappers_7.6/misc.c 2011-08-15 05:51:02.289091985 -0400
|
Date: Tue Feb 23 17:28:15 2016 +0100
|
||||||
@@ -35,7 +35,7 @@ FILE *fp;
|
|
||||||
|
tcp_wrappers-7.6-xgets.patch
|
||||||
|
|
||||||
|
diff --git a/misc.c b/misc.c
|
||||||
|
index b248a5d..204546c 100644
|
||||||
|
--- a/misc.c
|
||||||
|
+++ b/misc.c
|
||||||
|
@@ -35,20 +35,32 @@ FILE *fp;
|
||||||
|
{
|
||||||
int got;
|
int got;
|
||||||
char *start = ptr;
|
char *start = ptr;
|
||||||
|
+ int c, last;
|
||||||
|
|
||||||
- while (fgets(ptr, len, fp)) {
|
- while (fgets(ptr, len, fp)) {
|
||||||
+ while (len && fgets(ptr, len, fp)) {
|
+ while (len && fgets(ptr, len, fp)) {
|
||||||
got = strlen(ptr);
|
got = strlen(ptr);
|
||||||
if (got >= 1 && ptr[got - 1] == '\n') {
|
if (got >= 1 && ptr[got - 1] == '\n') {
|
||||||
tcpd_context.line++;
|
tcpd_context.line++;
|
||||||
|
if (got >= 2 && ptr[got - 2] == '\\') {
|
||||||
|
- got -= 2;
|
||||||
|
+ got -= 2;
|
||||||
|
} else {
|
||||||
|
- return (start);
|
||||||
|
+ return (start);
|
||||||
|
}
|
||||||
|
+ ptr += got;
|
||||||
|
+ len -= got;
|
||||||
|
+ ptr[0] = 0;
|
||||||
|
+ } else {
|
||||||
|
+ /* over buffer len */
|
||||||
|
+ last = (got >= 1) ? ptr[got - 1] : '\0';
|
||||||
|
+ while ((c = fgetc(fp)) != EOF) {
|
||||||
|
+ if (c == '\n') {
|
||||||
|
+ tcpd_context.line++;
|
||||||
|
+ if (last != '\\')
|
||||||
|
+ return (start);
|
||||||
|
+ }
|
||||||
|
+ last = c;
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
- ptr += got;
|
||||||
|
- len -= got;
|
||||||
|
- ptr[0] = 0;
|
||||||
|
}
|
||||||
|
return (ptr > start ? start : 0);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue