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

static analysis warnings #2810

Open
reinerh opened this issue Jun 29, 2019 · 3 comments
Open

static analysis warnings #2810

reinerh opened this issue Jun 29, 2019 · 3 comments
Labels
bug Something isn't working

Comments

@reinerh
Copy link
Collaborator

reinerh commented Jun 29, 2019

When building firejail with the clang static analyzer (scan-build), it reports a few warnings.

syscall.c:563:4: warning: Potential leak of memory pointed to by 'newcall'
                        free(newcall);
                        ^~~~
syscall.c:563:4: warning: Potential memory leak
                        free(newcall);
                        ^~~~
syscall.c:568:1: warning: Potential memory leak
}
paths.c:76:2: warning: Potential leak of memory pointed to by 'elt'
        assert(paths[i] == 0);
        ^~~~~~~~~~~~~~~~~~~~~

It would be nice to get rid of them. Then the check could also be enabled in the CI.

@netblue30 netblue30 added the bug Something isn't working label Jun 30, 2019
@netblue30
Copy link
Owner

I'll fix them, they are part of "make scan-build". I assume you are on the upcoming Debian version.

@rusty-snake
Copy link
Collaborator

@netblue30 any progress here? I still get this warnings with firejail 26ae0b2 under Fedora.
I get also a warning for firemon:

firemon.c:107:2: warning: The left expression of the compound assignment is an uninitialized value. The computed value will also be garbage
        FD_SET(0,&fds);
        ^~~~~~~~~~~~~~
/usr/include/sys/select.h:85:28: note: expanded from macro 'FD_SET'
#define FD_SET(fd, fdsetp)      __FD_SET (fd, fdsetp)
                                ^~~~~~~~~~~~~~~~~~~~~
/usr/include/bits/select.h:59:43: note: expanded from macro '__FD_SET'
  ((void) (__FDS_BITS (set)[__FD_ELT (d)] |= __FD_MASK (d)))

@matu3ba
Copy link
Contributor

matu3ba commented Dec 29, 2019

@netblue30 Having a look into the scan-build in line 1604 and 1609 there were 3 cases of memory leak detected.
BugGroup BugType File Function/Method Line PathLength
Memoryerror Memoryleak syscall.c syscall_in_list 1609 71
Memoryerror Memoryleak syscall.c syscall_in_list 1604 81
Memoryerror Memoryleak syscall.c syscall_in_list 1604 54

Sadly the tool does not give the exact path to the file (only syscall.c instead of fseccomp/syscall.c)
and in two cases for paths not the exact ressource(s), which were leaking.

Potential leak of memory pointed to by newcall looks to me like the tool cant keep track of static memory and somehow thinks (due to macros?) that it is dynamic memory.
Syslist looks like a compile-time generated static memory assignment.
What is your opinion on that?

It is interesting, that there is no implicit memory freeing on call of errExit. How is this handled?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants