Move definition of _FORTIFY_SOURCE to nsjail.h
authorSergiusz 'q3k' Bazański <q3k@q3k.org>
Wed, 20 Jan 2016 19:21:27 +0000 (20:21 +0100)
committerSergiusz 'q3k' Bazański <q3k@q3k.org>
Wed, 20 Jan 2016 19:21:27 +0000 (20:21 +0100)
This lets us undefine any built-in gcc macro. Otherwise, a redefinition
from the command line occurs and a warning is thrown, breaking the build
(due to -Werror).

Makefile
nsjail.h

index 1b3ccbc2af0e4ac13559acb49ab429e435d2adfb..53b624f998b80b479f263e1fd8ec542af660a0e8 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -20,7 +20,7 @@
 CC = gcc
 CFLAGS += -O2 -g -ggdb -c -std=c11 \
        -D_GNU_SOURCE \
-       -fstack-protector-all -Wformat -Wformat=2 -Wformat-security -fPIE -D_FORTIFY_SOURCE=2 -Wa,--noexecstack \
+       -fstack-protector-all -Wformat -Wformat=2 -Wformat-security -fPIE -Wa,--noexecstack \
        -Wall -Wextra -Werror
 
 LD = gcc
index 0df5319757e8275d5ec294afc06af076989465f4..4771f3b0ed636fc13fe6f5d75b7cfec7d67b38a5 100644 (file)
--- a/nsjail.h
+++ b/nsjail.h
@@ -4,6 +4,7 @@
    -----------------------------------------
 
    Copyright 2014 Google Inc. All Rights Reserved.
+   Copyright 2016 Sergiusz Bazanski. All Rights Reserved.
 
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
 #ifndef _NSJAIL_H
 #define _NSJAIL_H
 
+#ifdef _FORTIFY_SOURCE
+#undef _FORTIFY_SOURCE
+#endif              /* _FORTIFY_SOURCE */
+
+#define _FORTIFY_SOURCE 2
+
 #endif                         /* _NSJAIL_H */