From a17eb8dec4970b26fd44ba31baf7f66de95ca0e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Tue, 21 May 2019 17:56:58 +0000 Subject: [PATCH 1/2] Exit the ./gen program on failed readdir() call (cherry picked from commit 05b7c08a16eae9519473c61b947ea7137887b4a9) --- lib/dns/gen-unix.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/dns/gen-unix.h b/lib/dns/gen-unix.h index 84c3e7f78f..16b7524130 100644 --- a/lib/dns/gen-unix.h +++ b/lib/dns/gen-unix.h @@ -28,8 +28,10 @@ #include /* Required on some systems for dirent.h. */ +#include #include #include +#include #include /* XXXDCL Required for ?. */ #include @@ -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) From f7050fc7282683d5b29a9d66f7293a95c3c19fe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Mon, 27 May 2019 16:11:11 +0200 Subject: [PATCH 2/2] Use getconf LFS_{CFLAGS,LDFLAGS,LIBS} to get flags to compile lib/dns/gen On some systems (namely Debian buster armhf) the readdir() call fails with `Value too large for defined data type` unless the _FILE_OFFSET_BITS=64 is defined. The correct way to fix this is to get the appropriate compilation parameters from getconf system interface. (cherry picked from commit 4c7345bcb6646f3690cc33154d43fcd9ebceed69) --- lib/dns/Makefile.in | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/dns/Makefile.in b/lib/dns/Makefile.in index dc9d521632..b7693f0921 100644 --- a/lib/dns/Makefile.in +++ b/lib/dns/Makefile.in @@ -167,9 +167,14 @@ include/dns/rdatastruct.h: gen \ code.h: gen ./gen -s ${srcdir} > code.h || { rm -f $@ ; exit 1; } +gen: LFS_CFLAGS = `getconf LFS_CFLAGS 2>/dev/null` +gen: LFS_LDFLAGS = `getconf LFS_LDFLAGS 2>/dev/null` +gen: LFS_LIBS = `getconf LFS_LIBS 2>/dev/null` gen: gen.c ${BUILD_CC} ${BUILD_CFLAGS} -I${top_srcdir}/lib/isc/include \ - ${BUILD_CPPFLAGS} ${BUILD_LDFLAGS} -o $@ ${srcdir}/gen.c ${BUILD_LIBS} + ${LFS_CFLAGS} ${LFS_LDFLAGS} \ + ${BUILD_CPPFLAGS} ${BUILD_LDFLAGS} -o $@ ${srcdir}/gen.c \ + ${BUILD_LIBS} ${LFS_LIBS} timestamp: include libdns.@A@ touch timestamp