Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scan-build: 7 bugs found. #3

Closed
tklengyel opened this issue Jan 31, 2021 · 1 comment · Fixed by #5
Closed

scan-build: 7 bugs found. #3

tklengyel opened this issue Jan 31, 2021 · 1 comment · Fixed by #5
Assignees

Comments

@tklengyel
Copy link

diff --git a/Makefile b/Makefile
index eb9d46d..3702b58 100644
--- a/Makefile
+++ b/Makefile
@@ -16,8 +16,8 @@ LIBS := $(foreach lib,$(LIB_DEPS),-l$(lib))
 OBJS := $(patsubst %.c,%.o,$(SRCS))
 INC := -Iinc/ -Ilibs/ -I/usr/include/libxml2
 
-CFLAGS += -Wall -Werror -Wextra -fshort-wchar -fstack-protector -O2 \
-                 -fstack-clash-protection
+#CFLAGS += -Wall -Werror -Wextra -fshort-wchar -fstack-protector -O2 \
+#                -fstack-clash-protection
 
 all:        ## Build uefistored (same as uefistored target)
 all: uefistored uefistored-debug
@@ -25,15 +25,15 @@ all: uefistored uefistored-debug
 
 uefistored: ## Build uefistored
 uefistored: src/main.c $(OBJS)
-       gcc -o $@ $< $(LIBS) $(CFLAGS) $(OBJS) $(INC)
+       $(CC) -o $@ $< $(LIBS) $(CFLAGS) $(OBJS) $(INC)
 
 uefistored-debug: CFLAGS += -g -grecord-gcc-switches
 uefistored-debug: ## Build uefistored with debug symbols
 uefistored-debug: src/main.c $(OBJS)
-       gcc -o $@ $< $(LIBS) $(CFLAGS) $(OBJS) $(INC)
+       $(CC) -o $@ $< $(LIBS) $(CFLAGS) $(OBJS) $(INC)
 
 %.o: %.c
-       gcc -o $@ -c $< $(LIBS) $(CFLAGS) $(INC)
+       $(CC) -o $@ -c $< $(LIBS) $(CFLAGS) $(INC)
 
 .PHONY: clean
 clean:
scan-build --status-bugs -analyze-headers make

The bugs found are mostly benign but there is a doublefree. I also saw this while playing with the build settings that might be worth fixing with a 0600 added as third parameter to open:

In file included from /usr/include/fcntl.h:301,
                 from src/main.c:14:
In function ‘open’,
    inlined from ‘write_pidfile’ at src/main.c:144:10,
    inlined from ‘main’ at src/main.c:888:9:
/usr/include/x86_64-linux-gnu/bits/fcntl2.h:50:4: error: call to ‘__open_missing_mode’ declared with attribute error: open with O_CREAT or O_TMPFILE in second argument needs 3 arguments
   50 |    __open_missing_mode ();
      |    ^~~~~~~~~~~~~~~~~~~~~~
@beshleman
Copy link
Contributor

Thanks @tklengyel . I've just written a patch to fix all the issues reported by scan-build (and the open() 0600) and will close this when it's merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants