]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: pattern: handle errors from fgets when trying to load patterns
authorJerome Magnin <jmagnin@haproxy.com>
Fri, 17 Jan 2020 15:09:33 +0000 (16:09 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 17 Jan 2020 16:09:50 +0000 (17:09 +0100)
We need to do some error handling after we call fgets to make sure everything
went fine. If we don't users can be fooled into thinking they can load pattens
from directory because cfgparse doesn't flinch. This applies to acl patterns
map files.

This should be backported to all supported versions.

src/pattern.c

index ec7e9556ae93b01cab460e3c9bc7ba2555bc6c4c..33e0e17f275d4345465d93b6c09d0f5380e41a88 100644 (file)
@@ -2328,6 +2328,11 @@ int pat_ref_read_from_file_smp(struct pat_ref *ref, const char *filename, char *
                }
        }
 
+       if (ferror(file)) {
+               memprintf(err, "error encountered while reading  <%s> : %s",
+                               filename, strerror(errno));
+               goto out_close;
+       }
        /* succes */
        ret = 1;
 
@@ -2385,6 +2390,11 @@ int pat_ref_read_from_file(struct pat_ref *ref, const char *filename, char **err
                }
        }
 
+       if (ferror(file)) {
+               memprintf(err, "error encountered while reading  <%s> : %s",
+                               filename, strerror(errno));
+               goto out_close;
+       }
        ret = 1; /* success */
 
  out_close: