diff options
author | Stefan Brüns <stefan.bruens@rwth-aachen.de> | 2021-12-13 16:31:39 +0100 |
---|---|---|
committer | Stefan Brüns <stefan.bruens@rwth-aachen.de> | 2021-12-13 16:31:39 +0100 |
commit | 50a624bdd3ad1807d71178703f456811b7e8fb50 (patch) | |
tree | 1bedada67748bde6a998dbcc6dc36ba919a21c5c | |
parent | 7cc63be350a7b2c2ed9a502c965d22adb37a2b17 (diff) |
Fix segfaults due to strict ISO C99 mode enforcement
Commit 7cc63be350a7 ("Makefile: Add support for POSIX make) changed
the compilation mode to strict ISO C99 (-std=c99), which removed the
declarations of strdup and strcasecmp. As the implicit return value is
int instead of char*, the upper address bytes are discarded on e.g.
x86_64 (sizeof(int) == 4), the resulting code crashes.
Add the declarations back by using Posix 2008 mode, and also include
strings.h where required for strcasecmp.
Compilation may still fail when the compiler binary is not available as
c99, .POSIX mode sets CC=c99. Use e.g. "CC=cc make all" to circumvent.
-rw-r--r-- | src/Makefile | 2 | ||||
-rw-r--r-- | src/test-mime-data.c | 1 | ||||
-rw-r--r-- | src/test-mime.c | 1 |
3 files changed, 3 insertions, 1 deletions
diff --git a/src/Makefile b/src/Makefile index 9d2fc4d..44c44f7 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,7 +1,7 @@ .POSIX: .PHONY: all clean -C_STD = -std=c99 +C_STD = -std=c99 -D_POSIX_C_SOURCE=200809L ALL_CFLAGS = $(C_STD) -c -g -DXDG_PREFIX=xdg_test -DHAVE_MMAP -Wall -Wmissing-prototypes -Wno-sign-compare $(CFLAGS) .c.o: diff --git a/src/test-mime-data.c b/src/test-mime-data.c index df5a650..29d0d47 100644 --- a/src/test-mime-data.c +++ b/src/test-mime-data.c @@ -27,6 +27,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <strings.h> #include <libgen.h> #include "xdgmime.h" diff --git a/src/test-mime.c b/src/test-mime.c index e68222a..634b545 100644 --- a/src/test-mime.c +++ b/src/test-mime.c @@ -23,6 +23,7 @@ #include "xdgmime.h" #include "xdgmimeglob.h" #include <string.h> +#include <strings.h> #include <stdio.h> |