]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
logger: fail when io vector number exceeds maximum
authorSami Kerola <kerolasa@iki.fi>
Sun, 11 May 2014 19:26:41 +0000 (20:26 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 12 May 2014 11:07:06 +0000 (13:07 +0200)
Earlier version silently failed without logging anything.

$ logger --journald=/etc/services ; echo $?
1

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
misc-utils/logger.c

index f3bdc903baf1235c6104f691c4a6210fbaea212c..fccba3880ce508312442c64129fed96d347a6117 100644 (file)
@@ -37,6 +37,7 @@
  */
 
 #include <errno.h>
+#include <limits.h>
 #include <unistd.h>
 #include <stdlib.h>
 #include <time.h>
@@ -231,6 +232,8 @@ static int journald_entry(FILE *fp)
                }
                if (lines == vectors) {
                        vectors *= 2;
+                       if (IOV_MAX < vectors)
+                               errx(EXIT_FAILURE, _("maximum input lines (%d) exceeded"), IOV_MAX);
                        iovec = xrealloc(iovec, vectors * sizeof(struct iovec));
                }
                iovec[lines].iov_base = buf;
@@ -415,7 +418,9 @@ int main(int argc, char **argv)
                int ret = journald_entry(jfd);
                if (stdin != jfd)
                        fclose(jfd);
-               return ret ? EXIT_FAILURE : EXIT_SUCCESS;
+               if (ret)
+                       errx(EXIT_FAILURE, "journald entry could not be wrote");
+               return EXIT_SUCCESS;
        }
 #endif
        if (server)