Bug 6398 - [PATCH] Memory leaks in source4/client/smbumount.c
Summary: [PATCH] Memory leaks in source4/client/smbumount.c
Status: RESOLVED WONTFIX
Alias: None
Product: Samba 4.0
Classification: Unclassified
Component: Other (show other bugs)
Version: unspecified
Hardware: All All
: P3 trivial (vote)
Target Milestone: ---
Assignee: Andrew Bartlett
QA Contact: Andrew Bartlett
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-05-23 07:05 UTC by Slava Semushin
Modified: 2009-05-29 10:45 UTC (History)
0 users

See Also:


Attachments
Reorder checks to avoid strlen(NULL) call (885 bytes, patch)
2009-05-23 07:07 UTC, Slava Semushin
no flags Details
Fix for 2 possible memory leaks in source4/client/smbumount.c (1.25 KB, patch)
2009-05-23 07:08 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-23 07:05:51 UTC
Hello!

cppcheck found two possible memory leaks in canonicalize() function in file source4/client/smbumount.c See patch in attach.

Also I made another patch which reorder checks to avoid strlen(NULL) call.
Comment 1 Slava Semushin 2009-05-23 07:07:23 UTC
Created attachment 4193 [details]
Reorder checks to avoid strlen(NULL) call
Comment 2 Slava Semushin 2009-05-23 07:08:05 UTC
Created attachment 4194 [details]
Fix for 2 possible memory leaks in source4/client/smbumount.c

Proposal patch.
Comment 3 Slava Semushin 2009-05-23 07:11:44 UTC
BTW, in some cases we may not check path to NULL and just call relapath() with second argument equals to NULL:

       If  resolved_path is specified as NULL, then realpath() uses malloc(3) to allocate a buffer of
       up to PATH_MAX bytes to hold the resolved pathname, and returns a pointer to this buffer.  The
       caller should deallocate this buffer using free(3).

But:

      POSIX.1-2001 says that the  behavior  if  resolved_path  is  NULL  is  implementation-defined.
       POSIX.1-2008 specifies the behavior described in this page.

And this may be not portable :-(
Comment 4 Matthias Dieter Wallnöfer 2009-05-29 10:45:55 UTC
This will not be fixed since we don't support smbmount/smbumount anymore. See http://gitweb.samba.org/samba.git/?p=samba.git;a=commitdiff;h=e8ea854f0262ea2a1449695a0c70bea40bfbb872