Subject: bin/26514: cpio(1)'s handling of hardlinks is broken
To: None <gnats-bugs@gnats.NetBSD.org>
From: Matthias Scheler <tron@zhadum.de>
List: netbsd-bugs
Date: 08/02/2004 15:32:21
>Number:         26514
>Category:       bin
>Synopsis:       cpio(1)'s handling of hardlinks is broken
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Aug 02 13:33:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator:     
>Release:        NetBSD 2.0_BETA (also broken in 2004-08-02 current)
>Organization:
Matthias Scheler                                  http://scheler.de/~matthias/
>Environment:
System: NetBSD colwyn.zhadum.de 2.0_BETA NetBSD 2.0_BETA (COLWYN) #0: Mon Jul 26 12:22:36 CEST 2004 tron@colwyn.zhadum.de:/src/sys/compile/COLWYN i386
Architecture: i386
Machine: i386
>Description:
NetBSD 2.0's "cpio" doesn't handle hardlinks in cpio archives properly:

tron@colwyn:~/bla>rpm2cpio /src/distfiles/suse73/i386/glibc-2.2.4-78.i386.rpm | cpio -i -d
tron@colwyn:~/bla>find * -name LC_NAME -size 0c
usr/lib/locale/af_ZA/LC_NAME
usr/lib/locale/ar_AE/LC_NAME
usr/lib/locale/ar_BH/LC_NAME
usr/lib/locale/ar_DZ/LC_NAME
usr/lib/locale/ar_EG/LC_NAME
[...]
usr/lib/locale/vi_VN.utf8/LC_NAME
usr/lib/locale/zh_CN.utf8/LC_NAME
usr/lib/locale/zh_TW.utf8/LC_NAME
tron@colwyn:~/bla>

If I extract the same archive with NetBSD 1.6's "cpio" ...

tron@colwyn:~/bla>rpm2cpio /src/distfiles/suse73/i386/glibc-2.2.4-78.i386.rpm | ~/cpio -i -d
53508 blocks
tron@colwyn:~/bla>find * -name LC_NAME -size 0c
tron@colwyn:~/bla>

... or "gcpio" from "pkgsrc" ...

tron@colwyn:~/bla>
tron@colwyn:~/bla>rpm2cpio /src/distfiles/suse73/i386/glibc-2.2.4-78.i386.rpm | gcpio -i -d
53508 blocks
tron@colwyn:~/bla>!find
find * -name LC_NAME -size 0c
tron@colwyn:~/bla>

... there is no problem.

Or cpio(1) expects that the contents of the file is attached to the first
and not to the last hardlink. But that's often not the case:

-rw-r--r-- 18 root     wheel          0 Apr  1  2003 usr/lib/locale/ca_ES@euro/LC_NAME
-rw-r--r-- 18 root     wheel          0 Apr  1  2003 usr/lib/locale/de_AT@euro/LC_NAME == usr/lib/locale/ca_ES@euro/LC_NAME
[...]
-rw-r--r-- 18 root     wheel         68 Apr  1  2003 usr/lib/locale/sv_FI@euro/LC_NAME == usr/lib/locale/ca_ES@euro/LC_NAME

>How-To-Repeat:
Use "cpio" on an archive with hardlinks where the contents of the file
is attached to the last hardlink.


>Fix:
None provided.

>Release-Note:
>Audit-Trail:
>Unformatted: