Bug 1289 - memleak in copy_service
memleak in copy_service
Status: CLOSED FIXED
Product: Samba 3.0
Classification: Unclassified
Component: File Services
3.0.2a
All All
: P3 normal
: none
Assigned To: Samba Bugzilla Account
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2004-04-22 18:49 UTC by Chris Pascoe
Modified: 2005-08-24 10:17 UTC (History)
0 users

See Also:


Attachments
potential fix (531 bytes, patch)
2004-04-22 18:52 UTC, Chris Pascoe
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Pascoe 2004-04-22 18:49:25 UTC
copy_service leaks memory when copying any P_LIST variable
that has an alias, e.g. hosts allow, allow hosts.  This is
as the str_list_copy occurs once for each alias variant
and the already copied *dest_ptr is discarded before the
second copy takes place.

lp_save_defaults combats this with a test at the start of
its copying loop to make it skip aliased items, but
copy_service lacks this, presumably because theorerically
a copymap could have the bit set only on an alias's
parm_table entry and not on the aliased name - which would
result in it not being copied.

This appeared to cause a considerable leak on my system
which has a large number of services, large 'hosts allow'
lists, and a fairly regularly changing configuration file.

I will upload a patch against 3.0.3rc1 that combats this 
by doing a str_list_free on any preexisting *dest_ptr 
before performing another str_list_copy.  I've looked 
briefly at the callers of copy_service and it looks like 
it should be safe.

Regards
Chris
--
Christopher Pascoe
IT Infrastructure Manager
School of Information Technology and Electrical Engineering
The University of Queensland   Brisbane  QLD  4072  Australia
Comment 1 Chris Pascoe 2004-04-22 18:52:39 UTC
Created attachment 473 [details]
potential fix
Comment 2 Jeremy Allison 2004-05-20 15:36:47 UTC
Applied - thanks !
Jeremy.
Comment 3 Gerald (Jerry) Carter 2005-02-07 07:39:54 UTC
originally reported against 3.0.3pre1.  Moving back to version to 3.0.2a
to remove preX and rcX versions.
Comment 4 Gerald (Jerry) Carter 2005-02-07 07:42:14 UTC
originally reported against 3.0.3pre2.  Moving back to version to 3.0.2a
to remove preX and rcX versions.
Comment 5 Gerald (Jerry) Carter 2005-08-24 10:17:16 UTC
sorry for the same, cleaning up the database to prevent unecessary reopens of bugs.