Bug 611

Summary: ar command fails with "invalid ar header" with archive containing long file names
Product: Busybox Reporter: temasp
Component: OtherAssignee: unassigned
Status: RESOLVED FIXED    
Severity: major CC: busybox-cvs
Priority: P5    
Version: 1.13.x   
Target Milestone: ---   
Hardware: Other   
OS: Linux   
Host: Target:
Build:
Attachments: Fix

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.