The Samba-Bugzilla – Bug 6392
[PATCH] log2pcaphex: uncorrect behavior when we cannot open output file
Last modified: 2009-06-05 03:14:20 UTC
Looks like a bug:
const char *infile, *outfile;
FILE *out, *in;
outfile = poptGetArg(pc);
out = fopen(outfile, "w+");
fprintf(stderr, "Can't find %s, using stdout...\n", outfile);
if(!outfile) out = stdout;
When we can't open specified file program should use stdout, but out variable not assigned to stdout because outfile contains filename.
So, we should NULL'ify outfile to pass this checks, or change condition to compare out with NULL (in this case we also should initialize this variable).
I made a trivial patch which just assign NULL to outfile when we can't open file.
Created attachment 4186 [details]
Really use stdout if file cannot be opened.
I'd rather see the program to exit if we can't open a file a user explicitly asked to open. Do you want to provide a new patch with that, or do you want me to do it?
(In reply to comment #2)
> I'd rather see the program to exit if we can't open a file a user explicitly
> asked to open. Do you want to provide a new patch with that, or do you want me
> to do it?
It's not my idea, so I think it would be better if you implement it.
Pushed to master with c8d63d47cd38. I hope you don't mind I don't push this into the other branches, I don't think this is really criticial enough.