Date: Sun, 17 Mar 1996 12:38:00 -0500 (EST) From: "Brian R. Haug" <haug@dorothy.columbiasc.attgis.com> To: hackers@freebsd.org Cc: brian.haug@columbiasc.ncr.com Subject: changes to cpio Message-ID: <199603171738.MAA03032@dorothy.columbiasc.attgis.com>
next in thread | raw e-mail | index | archive | help
The cpio utility gets into an infinite loop with the following input and command line: cpio -i <cpio.out2 a b The cpio.out2 was constructed on a System V.4 system with the following command sequence: echo foo >a ln a b ln b c ls | cpio -oc >cpio.out2 begin 644 cpio.out2 M,#<P-S`Q,#`P,#0Y.34P,#`P.#%A,#`P,#`P,#<R,#`P,#`P,#$P,#`P,#`P M,S,Q-&,X8V$W,#`P,#`P,#`P,#`P,#`R,S`P,#`P,#!E,#`P,#`P,#`P,#`P M,#`P,#`P,#`P,#`R,#`P,#`P,#!A`#`W,#<P,3`P,#`T.3DU,#`P,#@Q83`P M,#`P,#`W,C`P,#`P,#`Q,#`P,#`P,#,S,31C.&-A-S`P,#`P,#`P,#`P,#`P M,C,P,#`P,#`P93`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,C`P,#`P,#`P8@`P M-S`W,#$P,#`P-#DY-3`P,#`X,6$P,#`P,#`P-S(P,#`P,#`P,3`P,#`P,#`S M,S$T8SAC83<P,#`P,#`P-#`P,#`P,#(S,#`P,#`P,&4P,#`P,#`P,#`P,#`P M,#`P,#`P,#`P,#(P,#`P,#`P,&,`9F]O"C`W,#<P,3`P,#`P,#`P,#`P,#`P M,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#$P,#`P,#`P,#`P,#`P,#`P,#`P M,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P8C`P,#`P,#`P M5%)!24Q%4B$A(0`````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` !```` ` end The following diffs appear to correct the problem. diff -r -c usr/src/gnu/usr.bin/cpio.orig/copyin.c usr/src/gnu/usr.bin/cpio/copyin.c *** usr/src/gnu/usr.bin/cpio.orig/copyin.c Sun Mar 17 12:21:40 1996 --- usr/src/gnu/usr.bin/cpio/copyin.c Sun Mar 17 12:28:29 1996 *************** *** 38,43 **** --- 38,44 ---- static void defer_copyin (); static void create_defered_links (); static void create_final_defers (); + int check_for_deferments(struct new_cpio_header *file_hdr); /* Return 16-bit integer I with the bytes swapped. */ #define swab_short(i) ((((i) << 8) & 0xff00) | (((i) >> 8) & 0x00ff)) *************** *** 484,489 **** --- 485,493 ---- if (fnmatch (save_patterns[i], file_hdr.c_name, 0) == 0) skip_file = !copy_matching_files; } + if (skip_file) { + skip_file = check_for_deferments(&file_hdr); + } } if (skip_file) *************** *** 1269,1272 **** --- 1273,1300 ---- error (0, errno, "%s", d->header.c_name); } } + } + + int + check_for_deferments(struct new_cpio_header *file_hdr) + { + struct deferment *d; + struct deferment *prev = NULL; + + for (d = deferments; d != NULL; d = d->next) { + if (file_hdr->c_ino == d->header.c_ino && + file_hdr->c_dev_maj == d->header.c_dev_maj && + file_hdr->c_dev_min == d->header.c_dev_min) { + free(file_hdr->c_name); + if (prev != NULL) + prev->next = d->next; + else + deferments = d->next; + file_hdr->c_name = strdup(d->header.c_name); + free_deferment(d); + return FALSE; + } + prev = d; + } + return TRUE; } Share and Enjoy! Brian
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199603171738.MAA03032>