[PATCH] missing padding in cpio_mkfile in usr/gen_init_cpio.c

From: Olaf Hering
Date: Sun Nov 16 2003 - 10:08:50 EST



Add this line to main() and booting will fail with panic:

cpio_mkfile("t", "/sbin/init", 0700, 0, 0);


olaf@nectarine:~/kernel/pineapple/linuxppc-2.5> echo > t
olaf@nectarine:~/kernel/pineapple/linuxppc-2.5> gcc -o foo usr/gen_init_cpio.c.kaputt.c && ./foo | tee bar | cpio -vt
drwxr-xr-x 2 root root 0 Nov 16 16:06 /dev
crw------- 1 root root 5, 1 Nov 16 16:06 /dev/console
drwx------ 2 root root 0 Nov 16 16:06 /root
-rwx------ 1 root root 1 Nov 16 16:05 /sbin/init
cpio: premature end of file
olaf@nectarine:~/kernel/pineapple/linuxppc-2.5> gcc -o foo usr/gen_init_cpio.c && ./foo | tee bar | cpio -vt
drwxr-xr-x 2 root root 0 Nov 16 16:06 /dev
crw------- 1 root root 5, 1 Nov 16 16:06 /dev/console
drwx------ 2 root root 0 Nov 16 16:06 /root
-rwx------ 1 root root 1 Nov 16 16:05 /sbin/init
2 blocks
olaf@nectarine:~/kernel/pineapple/linuxppc-2.5> diff -pu usr/gen_init_cpio.c.kaputt.c usr/gen_init_cpio.c
--- usr/gen_init_cpio.c.kaputt.c 2003-11-16 16:03:27.000000000 +0100
+++ usr/gen_init_cpio.c 2003-11-16 16:02:12.000000000 +0100
@@ -197,6 +197,7 @@ void cpio_mkfile(const char *filename, c

for (i = 0; i < buf.st_size; ++i)
fputc(filebuf[i], stdout);
+ offset += buf.st_size;
close(file);
free(filebuf);
push_pad();

--
USB is for mice, FireWire is for men!

sUse lINUX ag, nÃRNBERG
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/