summaryrefslogtreecommitdiff
path: root/soltools
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2022-12-07 07:43:23 +0100
committerStephan Bergmann <sbergman@redhat.com>2022-12-07 12:35:45 +0000
commitcb26710b6b40df59f34dd6a65988cd55e32153b0 (patch)
treedbe5fa17b4f81e9e115f2d690ffdb01af4a9ec85 /soltools
parente0bf2712aa9e240748534e3a7498d41c8eeeb9d7 (diff)
Check for failed malloc
...thereby silencing > In file included from /usr/include/features.h:490, > from /usr/include/bits/libc-header-start.h:33, > from /usr/include/stdio.h:27, > from soltools/mkdepend/def.h:40, > from soltools/mkdepend/main.c:58: > In function ‘read’, > inlined from ‘main’ at soltools/mkdepend/main.c:197:28: > /usr/include/bits/unistd.h:38:10: error: ‘__read_alias’ specified size 18446744073709551614 exceeds maximum object size 9223372036854775807 [-Werror=stringop-overflow=] > 38 | return __glibc_fortify (read, __nbytes, sizeof (char), > | ^~~~~~~~~~~~~~~ > /usr/include/bits/unistd.h: In function ‘main’: > /usr/include/bits/unistd.h:26:16: note: in a call to function ‘__read_alias’ declared with attribute ‘access (write_only, 2, 3)’ > 26 | extern ssize_t __REDIRECT (__read_alias, (int __fd, void *__buf, > | ^~~~~~~~~~ seen at least with -Wp,-D_FORTIFY_SOURCE=3 manually added to gb_COMPILEROPTFLAGS in an --enable-optimized build against recent GCC 13 trunk Change-Id: I9ca3c0ea8c579fffbdad52d7d39a4ce82085ddcd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143760 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'soltools')
-rw-r--r--soltools/mkdepend/main.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/soltools/mkdepend/main.c b/soltools/mkdepend/main.c
index b8b84b453476..708d2c3b53dd 100644
--- a/soltools/mkdepend/main.c
+++ b/soltools/mkdepend/main.c
@@ -77,6 +77,7 @@ typedef _W64 int ssize_t;
#endif
#include <stdarg.h>
+#include <stdlib.h>
#ifdef MINIX
#define USE_CHMOD 1
@@ -194,6 +195,9 @@ int main(int argc, char **argv)
fatalerr("cannot open \"%s\"\n", argv[1]+1);
(void)fstat(afd, &ast);
args = (char *)malloc(ast.st_size + 1);
+ if (args == NULL) {
+ abort();
+ }
if ((ast.st_size = read(afd, args, (size_t) ast.st_size)) < 0)
fatalerr("failed to read %s\n", argv[1]+1);
args[ast.st_size] = '\0';