[PATCH] cpio hardlink support and possible memory leak fix

Denis Vlasenko vda.linux at googlemail.com
Sun Oct 15 20:07:52 UTC 2006


On Sunday 15 October 2006 16:45, Luciano Miguel Ferreira Rocha wrote:
> Attached is a patch that adds hard-link support for busybox's cpio.
> 
> I tested it with /usr/share/zoneinfo and it worked fine (both data,
> hardlinks, permissions and owner/group).
> 
> While adding it, I noticed that file_header->name was allocated but
> never freed:
> archival/libunarchive/get_header_cpio.c +77
>        file_header->name = (char *) xzalloc(namesize + 1);
> 
> As such, in the patch I send, I reuse it when creating hard links, and
> add a free(file_header->name) before the allocation. That means that
> there's no longer a memory leak for each filename (iff I'm reading the
> code correctly), but the memory for the last filename, the file_header and
> archive_handle is still allocated when cpio_main returns. As I don't
> know if busybox has a mode to execute internal commands without an exec,

Not yet.

> I don't know if that is serious.

Your patch didn't apply cleanly to svn. I applied it by hand.
Please test it and let me know is it ok (see attached).
--
vda
-------------- next part --------------
A non-text attachment was scrubbed...
Name: get_header_cpio.c
Type: text/x-csrc
Size: 4393 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20061015/6563e3b5/attachment-0002.c 


More information about the busybox mailing list