the-tcpdump-group / tcpslice

tcpslice concatenates multiple pcap files together, or extracts time slices from one or more pcap files.
63 stars 22 forks source link

Missing CPPFLAGS variable in Makefile.in #9

Closed brunonaibert closed 3 years ago

brunonaibert commented 3 years ago

During the compilation of the tcpslice .deb package I use blhc to check for hardening issues. Absence of CPPFLAGS was pointed out:

# blhc --all --debian ../tcpslice_1.3-1_amd64.build
CPPFLAGS missing (-D_FORTIFY_SOURCE = 2): gcc -g -O2 -fdebug-prefix-map = / PKGS / tcpslice / tcpslice =. -fstack-protector-strong -Wformat -Werror = format-security -c version.c

I don't know if it's the most suitable mode, I solved it with the following patch:

Index: tcpslice / Makefile.in
================================================== =================
--- tcpslice.orig / Makefile.in
+++ tcpslice / Makefile.in
@@ -127.7 +127.7 @@ $ (PROG): $ (OBJ) @ V_PCAPDEP @
         $ (CC) $ (FULL_CFLAGS) $ (LDFLAGS) -o $ @ $ (OBJ) $ (LIBS)

  version.o: version.c
- $ (CC) $ (CFLAGS) -c version.c
+ $ (CC) $ (CFLAGS) $ (CPPFLAGS) -c version.c

  version.c: $ (srcdir) / VERSION
         @rm -f $ @
infrastation commented 3 years ago

@guyharris, would this be better?

--- a/Makefile.in
+++ b/Makefile.in
@@ -127,7 +127,7 @@ $(PROG): $(OBJ) @V_PCAPDEP@
        $(CC) $(FULL_CFLAGS) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)

 version.o: version.c
-       $(CC) $(CFLAGS) -c version.c
+       $(CC) $(FULL_CFLAGS) -c version.c

 version.c: $(srcdir)/VERSION
        @rm -f $@
brunonaibert commented 3 years ago

@guyharris, would this be better?

--- a/Makefile.in
+++ b/Makefile.in
@@ -127,7 +127,7 @@ $(PROG): $(OBJ) @V_PCAPDEP@
        $(CC) $(FULL_CFLAGS) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)

 version.o: version.c
-       $(CC) $(CFLAGS) -c version.c
+       $(CC) $(FULL_CFLAGS) -c version.c

 version.c: $(srcdir)/VERSION
        @rm -f $@

Much better solution. Thanks. I modified it as suggested, ran the blhc and there were no warnings. It would be an interesting modification for a future version.

guyharris commented 3 years ago

That should work.

(We do the version stuff differently now for libpcap and tcpdump, without a version.c file; it's set as PACKAGE_VERSION in config.h in the configure script.)

infrastation commented 3 years ago

Found a better way to do it, this problem should be resolved now.

infrastation commented 3 years ago

Nope, that was not better, committed a fix to the "fix", in the end the diff discussed above (with FULL_CFLAGS) is the right fix.

infrastation commented 3 years ago

The resolution is that the next release will have the change that the original requestor confirmed working. Closing.