-
Notifications
You must be signed in to change notification settings - Fork 130
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
samba.c: popen() leaks via stderr #164
Conversation
gsize length; | ||
|
||
spawned = g_spawn_command_line_sync("net usershare list", | ||
&out, &err, &status, NULL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If stderr
is not required, you can pass NULL
instead of &err
; then there's no need to free()
it below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It appears that if you pass NULL, then stderr will still leak.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's leaking, it's a bug in GLib. It's marked as optional in the documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If NULL is passed, the following message appears in Terminal when Shared Directories is selected:
net usershare: cannot open usershare directory /var/lib/samba/usershares. Error No such file or directory
Please ask your system administrator to enable user sharing.
I don't know, but I think it could still be optional and just forward stderr to the application's stderr if it is NULL.
When it is captured in a string, the message does not appear in Terminal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see. LGTM, then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Patch LGTM, just a minor comment.
0ca5ae0
to
9ff175a
Compare
Signed-off-by: Burt P <pburt0@gmail.com>
Merged, thanks! |
Part of #162: Change samba.c to use g_spawn_command_line_sync() instead of popen() to prevent leaks via stderr.
Prevents this message from appearing:
The problem is that I have no "usershares", so I didn't test if it is otherwise still working. Will someone who does test that?