]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Exit the ./gen program on failed readdir() call
authorOndřej Surý <ondrej@sury.org>
Tue, 21 May 2019 17:56:58 +0000 (17:56 +0000)
committerOndřej Surý <ondrej@sury.org>
Wed, 29 May 2019 08:31:03 +0000 (10:31 +0200)
(cherry picked from commit 05b7c08a16eae9519473c61b947ea7137887b4a9)

lib/dns/gen-unix.h

index 84c3e7f78f35520da5af812ea3f895f7a24ca3b3..16b752413073c1737b082ef0327648e2fe592aaf 100644 (file)
 
 #include <sys/types.h>          /* Required on some systems for dirent.h. */
 
+#include <errno.h>
 #include <dirent.h>
 #include <stdbool.h>
+#include <stdlib.h>
 #include <unistd.h>            /* XXXDCL Required for ?. */
 
 #include <isc/lang.h>
@@ -66,9 +68,15 @@ next_file(isc_dir_t *dir) {
        dir->filename = NULL;
 
        if (dir->handle != NULL) {
+               errno = 0;
                dirent = readdir(dir->handle);
-               if (dirent != NULL)
+               if (dirent != NULL) {
                        dir->filename = dirent->d_name;
+               } else {
+                       if (errno != 0) {
+                               exit(1);
+                       }
+               }
        }
 
        if (dir->filename != NULL)