lkml.org 
[lkml]   [2003]   [Nov]   [16]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
DateSun, 16 Nov 2003 16:08:02 +0100
FromOlaf Hering <>
Subject[PATCH] missing padding in cpio_mkfile in usr/gen_init_cpio.c
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@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 12:58    [from the cache]
©2003-2008