-
Notifications
You must be signed in to change notification settings - Fork 478
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
segfault when given logfile name is already taken by a directory #853
Comments
The crash point is in 1042│ int main(int argc, char *argv[])
1043│ {
...
1080│ if (dbg_domain_set && !debug)
1081│ debug = 1;
1082│
1083│ if (opts.logfile) {
1084│ logfp = fopen(opts.logfile, "a");
1085│ if (logfp == NULL)
1086├───────────────────────> pr_err("cannot open log file");
1087│
1088│ setvbuf(logfp, NULL, _IOLBF, 1024);
1089│ }
1090│ else if (debug) {
1091│ /* ensure normal output is not mixed by debug message */
1092│ setvbuf(outfp, NULL, _IOLBF, 1024);
1093│ }
... |
This is a simple bug so anyone can fix this if interested. |
Can i take this issue? |
Sure, please take it. I would like to provide more info regarding this. Please refer to the following discussion. I think we better have some protection code for this. |
The problem seems to be caused by writing an error message to logfd when logfd is NULL. |
I'm okay with it. Thanks! |
If logfd is NULL, set logfd to stderr before calling pr_err(). Fixed: namhyung#853
…irectory This patch is to fix segfault in --logfile. If logfd is NULL, set logfd to stderr before calling pr_err(). Fixed: namhyung#853
This patch is to fix segfault in --logfile. If logfd is NULL, set logfd to stderr before calling pr_err(). Fixed: namhyung#853 Signed-off-by: MinJeong Kim <[email protected]>
This patch is to fix segfault in --logfile. If logfd is NULL, set logfd to stderr before calling pr_err(). Fixed: #853 Signed-off-by: MinJeong Kim <[email protected]>
Here is an example recording a simple program.
The above example works fine and the debug message can be stored with
--logfile
option as follows:However, it gets crashed if the given file name is already used by another directory as follows:
It needs to check if the file is already exists or not.
The text was updated successfully, but these errors were encountered: