Bug 6390 - [PATCH] File descriptor leak in source3/torture/vfstest.c
Summary: [PATCH] File descriptor leak in source3/torture/vfstest.c
Status: RESOLVED FIXED
Alias: None
Product: Samba 4.0
Classification: Unclassified
Component: Other (show other bugs)
Version: unspecified
Hardware: All All
: P3 trivial (vote)
Target Milestone: ---
Assignee: Volker Lendecke
QA Contact: Andrew Bartlett
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-05-22 12:54 UTC by Slava Semushin
Modified: 2009-06-05 03:18 UTC (History)
0 users

See Also:


Attachments
Fix for resource leak in source3/torture/vfstest.c (861 bytes, patch)
2009-05-22 12:55 UTC, Slava Semushin
no flags Details
Proper fix for resource leak in source3/torture/vfstest.c (858 bytes, patch)
2009-05-25 12:00 UTC, Slava Semushin
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Slava Semushin 2009-05-22 12:54:29 UTC
Hello!

In file source3/torture/vfstest.c in function process_file() leak file descriptor when we process file (not a standart input).

I made a trivial patch, but not sure I fix it gracefully: may be condition should be file != stdin? (it's probably more readable.)


Also, while I'm here, i found then this condition may be wrong in some cases:

	if (*filename == '-') {
		file = stdin;

Its only check first symbol of string. What will be if file has name starts from minus sign? File systems allow such files, but may be you program not (for example if you not use GNU getopt()).
Comment 1 Slava Semushin 2009-05-22 12:55:37 UTC
Created attachment 4184 [details]
Fix for resource leak in source3/torture/vfstest.c

Proposal patch.
Comment 2 Volker Lendecke 2009-05-25 09:24:41 UTC
Yes, the "file != stdin" would be more reliable. To fix the other problem you pointed out, you might want to use

strcmp(filename, "-") == 0

instead of

*filename == '-'

Volker
Comment 3 Slava Semushin 2009-05-25 11:59:52 UTC
(In reply to comment #2)
> Yes, the "file != stdin" would be more reliable.

I update patch.
Comment 4 Slava Semushin 2009-05-25 12:00:29 UTC
Created attachment 4202 [details]
Proper fix for resource leak in source3/torture/vfstest.c
Comment 5 Volker Lendecke 2009-06-05 03:18:05 UTC
Pushed with ecd1fe2, thanks!

Volker