Bug 783 - dpkg.c dot-directory extraction bug
Summary: dpkg.c dot-directory extraction bug
Status: RESOLVED FIXED
Alias: None
Product: Busybox
Classification: Unclassified
Component: Other (show other bugs)
Version: 1.13.x
Hardware: PC Linux
: P5 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-12-07 21:35 UTC by Michael Smith
Modified: 2010-01-30 23:18 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments
fix dot-dir extraction (789 bytes, patch)
2009-12-07 21:35 UTC, Michael Smith
Details
Fix dot-dir extraction v2 (891 bytes, patch)
2010-01-11 16:41 UTC, Michael Smith
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Smith 2009-12-07 21:35:36 UTC
Created attachment 809 [details]
fix dot-dir extraction

data_extract_all_prefix() is trying to remove the leading "./" from pathnames, but it will also catch a leading "./." so dot-directories don't get extracted happily.
Comment 1 Denys Vlasenko 2010-01-08 17:07:19 UTC
Your patch will mishandle ".name" by treating it like "name".

How about this?

-       name_ptr += strspn(name_ptr, "./");
+       /* Skip all leading "/" */
+       while (*name_ptr == '/')
+               name_ptr++;
+       /* Skip all leading "./" and "../" */
+       while (name_ptr[0] == '.') {
+               if (name_ptr[1] == '.' && name_ptr[2] == '/')
+                       name_ptr++;
+               if (name_ptr[1] != '/')
+                       break;
+               name_ptr += 2;
+       }
Comment 2 Michael Smith 2010-01-11 16:07:06 UTC
That's true. I haven't seen a deb data.tar where the entries don't start with "./", but there's no reason it couldn't happen.

I don't think we need to strip the leading "../". Looking in get_header_tar.c, it looks like anything beginning with "../" or containing "/../" is rejected.
Comment 3 Michael Smith 2010-01-11 16:41:49 UTC
Created attachment 889 [details]
Fix dot-dir extraction v2

OK, this one strips leading "/" and "./", but not ".name".
Comment 4 Denys Vlasenko 2010-01-30 23:18:07 UTC
Fixed in 1.16.0