Bug 611 - ar command fails with "invalid ar header" with archive containing long file names
Summary: ar command fails with "invalid ar header" with archive containing long file n...
Status: RESOLVED FIXED
Alias: None
Product: Busybox
Classification: Unclassified
Component: Other (show other bugs)
Version: 1.13.x
Hardware: Other Linux
: P5 major
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-09-17 13:42 UTC by temasp
Modified: 2009-10-08 00:16 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments
Fix (4.77 KB, patch)
2009-09-19 23:25 UTC, Denys Vlasenko
Details

Note You need to log in before you can comment on or make changes to this bug.
Description temasp 2009-09-17 13:42:18 UTC
Easy steps to reproduce:

create 2 files with short names (e.g. a.txt and b.txt)
create an archive containing these files: ar -q short.ar a.txt b.txt
busybox ar correctly interprets this file: ar -t short.ar

create 2 files with long names (e.g. thisisalongfilename.txt thisisanotherlongfilename.txt)
create an archive containing these files: ar -q long.ar thisisalongfilename.txt thisisanotherlongfilename.txt
busybox ar command fails with "invalid ar header": ar -t long.ar

See source file archival/libunarchive/get_header_ar.c. Function get_header_ar() attempts to read mode, date, uid, gid and size from the file file header; this works for "short" headers but fails for "long" headers. Function get_header_ar() does check for long file headers, but this check is not performed until after attempting to read the file header.

I created the archive files using Ubuntu 8.04.
I'm using BusyBox v1.13.1 (2009-09-16 11:20:36 EDT) multi-call binary (with CONFIG_FEATURE_AR_LONG_FILENAMES=y) but a check of the 1.15.1 source code shows this bug still exists.
Comment 1 temasp 2009-09-18 13:03:30 UTC
I forgot to say that I'm using BusyBox v1.13.1 on a Linux system with the 2.6.31 kernel.
Comment 2 Denys Vlasenko 2009-09-19 23:25:12 UTC
Created attachment 661 [details]
Fix

Please try this patch
Comment 3 temasp 2009-09-21 15:30:06 UTC
I tried the patch, it works. Busybox ar command correctly interprets short and long headers.