Skip to content
This repository was archived by the owner on Jan 27, 2024. It is now read-only.

Enable stack smashing protection - #315

Merged
BenWiederhake merged 3 commits into
majn:dev-1.3.0from
carpikes:dev-1.3.0
Oct 13, 2016
Merged

Enable stack smashing protection#315
BenWiederhake merged 3 commits into
majn:dev-1.3.0from
carpikes:dev-1.3.0

Conversation

@carpikes

Copy link
Copy Markdown
Contributor

Same PR as the one in tgl. It adds compiler flags "-fstack-protector-strong" and "-D_FORTIFY_SOURCE=2", they increase security (protecting from stack smashing) in a production environment and allow developers to find bugs easily.

@BenWiederhake

BenWiederhake commented Oct 13, 2016

Copy link
Copy Markdown
Collaborator
+ifeq "$(CC)" "gcc"

This is wrong, as it wouldn't recognize afl-gcc, gcc-${PLATFORM}. Also, it will probably break on Apple, as here gcc actually invokes clang.

Isn't there a better way to check for feature existence? This would also allw skipping the version check stuff.

EDIT: Enter / Ctrl-Enter is unintuitive.

@carpikes

carpikes commented Oct 13, 2016

Copy link
Copy Markdown
Contributor Author

The first two solutions that I can think are:

  1. $(CC) -fstack-protector-strong 2>&1 | grep 'stack-protector-strong' | wc -l.
    It returns 1 if is not available, 0 if it's available. But this command needs grep and wc.
  2. Check if the word 'gcc' is in the compiler name. (How?)

@BenWiederhake

Copy link
Copy Markdown
Collaborator

Your second option probably won't work reliably on Apple.

Your first option sounds perfect, as we use and expect grep anyway, and wc should be installed on most systems.

Thanks for your work, btw!

@carpikes

Copy link
Copy Markdown
Contributor Author

Perfect :) Just changed grep '...' | wc -l to grep -c '...', it should be the same, but faster.

@BenWiederhake

Copy link
Copy Markdown
Collaborator

Looks good. I'll squash it though, as two of three commits are just fixes of the first commit.

@BenWiederhake
BenWiederhake merged commit a904aa3 into majn:dev-1.3.0 Oct 13, 2016
@BenWiederhake

Copy link
Copy Markdown
Collaborator

I'm too dump to click 'squash', apparently. Other than that, let's hope the 2&>1 won't break on FreeBSD.

@rodneyrod

Copy link
Copy Markdown

@BenWiederhake Would you like someone to test that? I could download a FreeBSD VM tonight and give it a spin.

@BenWiederhake

Copy link
Copy Markdown
Collaborator

That would be nice, yes please.

@rodneyrod

Copy link
Copy Markdown

So I got a PC-BSD VM installed and I tried to build telegram-purple, I got ./configure to work after installing pkgconf but when I tried to make I got a 'Need an operator' error on lines 36, 38, 48 and 51, after that make fails.

Anything else you guys need to test feel free to ping me.

@BenWiederhake

Copy link
Copy Markdown
Collaborator

"Need an operator"? That doesn't sound like an error message from either Make, our makefile, the compiler, or anything else I know.
Can you give more details about the error message?

@rodneyrod

Copy link
Copy Markdown

I wish I could give you more details but that's all the make process spits out, no logs or anything AFAIK.
I can post the lines from the makefile that are causing issue here if that helps, I'm going to try and install FreeBSD instead, see if this issue persists with that.

@BenWiederhake

BenWiederhake commented Oct 16, 2016

Copy link
Copy Markdown
Collaborator

that's all the make process spits out

Well, telling us what it spits out would be a helpful start.

Also, please note that you'll need GNU make, not BSD make, and it's called gmake on FreeBSD, so maybe try that on PC-BSD. Easy way to check:

$ make --version
GNU Make 4.1

@rodneyrod

Copy link
Copy Markdown

Looks like I may have been using BSD make, will try again with gmake.

@rodneyrod

Copy link
Copy Markdown

gmake worked, forgot about that little BSD quirk, however it now fails with another error

gmake -C tgl libs/libtgl.a
gmake[1]: Entering directory '/usr/home/username/git/telegram-purple/tgl'
gcc -I. -I. -g -O2 -I/usr/local/include -I/usr/include -I/usr/include -DHAVE_CONFIG_H -Wall -Wextra -Werror -Wno-deprecated-declarations -fno-strict-aliasing -fno-omit-frame-pointer -ggdb -Wno-unused-parameter -fPIC -iquote ./tl-parser -c -MP -MD -MF dep/tl-parser.d -MQ objs/tl-parser.o -o objs/tl-parser.o tl-parser/tl-parser.c
In file included from tl-parser/tl-parser.c:38:0:
tl-parser/portable_endian.h:56:0: error: "be16toh" redefined [-Werror]

define be16toh(x) betoh16(x)

^
In file included from tl-parser/portable_endian.h:54:0,
from tl-parser/tl-parser.c:38:
/usr/include/sys/endian.h:75:0: note: this is the location of the previous definition
#define be16toh(x) bswap16((x))
^
In file included from tl-parser/tl-parser.c:38:0:
tl-parser/portable_endian.h:57:0: error: "le16toh" redefined [-Werror]

define le16toh(x) letoh16(x)

^
In file included from tl-parser/portable_endian.h:54:0,
from tl-parser/tl-parser.c:38:
/usr/include/sys/endian.h:78:0: note: this is the location of the previous definition
#define le16toh(x) ((uint16_t)(x))
^
In file included from tl-parser/tl-parser.c:38:0:
tl-parser/portable_endian.h:59:0: error: "be32toh" redefined [-Werror]

define be32toh(x) betoh32(x)

^
In file included from tl-parser/portable_endian.h:54:0,
from tl-parser/tl-parser.c:38:
/usr/include/sys/endian.h:76:0: note: this is the location of the previous definition
#define be32toh(x) bswap32((x))
^
In file included from tl-parser/tl-parser.c:38:0:
tl-parser/portable_endian.h:60:0: error: "le32toh" redefined [-Werror]

define le32toh(x) letoh32(x)

^
In file included from tl-parser/portable_endian.h:54:0,
from tl-parser/tl-parser.c:38:
/usr/include/sys/endian.h:79:0: note: this is the location of the previous definition
#define le32toh(x) ((uint32_t)(x))
^
In file included from tl-parser/tl-parser.c:38:0:
tl-parser/portable_endian.h:62:0: error: "be64toh" redefined [-Werror]

define be64toh(x) betoh64(x)

^
In file included from tl-parser/portable_endian.h:54:0,
from tl-parser/tl-parser.c:38:
/usr/include/sys/endian.h:77:0: note: this is the location of the previous definition
#define be64toh(x) bswap64((x))
^
In file included from tl-parser/tl-parser.c:38:0:
tl-parser/portable_endian.h:63:0: error: "le64toh" redefined [-Werror]

define le64toh(x) letoh64(x)

^
In file included from tl-parser/portable_endian.h:54:0,
from tl-parser/tl-parser.c:38:
/usr/include/sys/endian.h:80:0: note: this is the location of the previous definition
#define le64toh(x) ((uint64_t)(x))
^
cc1: all warnings being treated as errors
gmake[1]: *** [Makefile.tl-parser:4: objs/tl-parser.o] Error 1
gmake[1]: Leaving directory '/usr/home/username/git/telegram-purple/tgl'
gmake: *** [Makefile:87: tgl/libs/libtgl.a] Error 2

@BenWiederhake

BenWiederhake commented Oct 18, 2016

Copy link
Copy Markdown
Collaborator

I should have mentioned that you'll need to take care of a few things, as FreeBSD support is still a little rough, sorry: #260 (comment)

For instance, you'll need this PR: vysheng/tl-parser#12

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants