lkml.org 
[lkml]   [2002]   [Oct]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] 2.5.29-rdunzip
Date
This patch appears not to be in 2.5.43, but applies cleanly.

This patch ensures that we report failures when unzipping ramdisks and the
like, including if we fail to write to the ramdisk.

Unfortunately, there is no way to guarantee that the gunzip function will
ever terminate (gzip itself uses a setjmp and longjmp to achieve this).

init/do_mounts.c | 19 ++++++++++++++++---
1 files changed, 16 insertions, 3 deletions

diff -urN orig/init/do_mounts.c linux/init/do_mounts.c
--- orig/init/do_mounts.c Sat Jul 27 13:55:25 2002
+++ linux/init/do_mounts.c Sat Jul 27 14:13:56 2002
@@ -877,6 +877,7 @@
static unsigned inptr; /* index of next byte to be processed in inbuf */
static unsigned outcnt; /* bytes in output buffer */
static int exit_code;
+static int unzip_error;
static long bytes_out;
static int crd_infd, crd_outfd;

@@ -924,13 +925,17 @@
/* ===========================================================================
* Fill the input buffer. This is called only when the buffer is empty
* and at least one byte is really needed.
+ * Returning -1 does not guarantee that gunzip() will ever return.
*/
static int __init fill_inbuf(void)
{
if (exit_code) return -1;

insize = read(crd_infd, inbuf, INBUFSIZ);
- if (insize == 0) return -1;
+ if (insize == 0) {
+ error("RAMDISK: ran out of compressed data\n");
+ return -1;
+ }

inptr = 1;

@@ -944,10 +949,15 @@
static void __init flush_window(void)
{
ulg c = crc; /* temporary variable */
- unsigned n;
+ unsigned n, written;
uch *in, ch;

- write(crd_outfd, window, outcnt);
+ written = write(crd_outfd, window, outcnt);
+ if (written != outcnt && unzip_error == 0) {
+ printk(KERN_ERR "RAMDISK: incomplete write (%d != %d) %d\n",
+ written, outcnt, bytes_out);
+ unzip_error = 1;
+ }
in = window;
for (n = 0; n < outcnt; n++) {
ch = *in++;
@@ -962,6 +972,7 @@
{
printk(KERN_ERR "%s", x);
exit_code = 1;
+ unzip_error = 1;
}

static int __init crd_load(int in_fd, int out_fd)
@@ -990,6 +1001,8 @@
}
makecrc();
result = gunzip();
+ if (unzip_error)
+ result = 1;
kfree(inbuf);
kfree(window);
return result;
-
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 13:30    [W:0.032 / U:0.092 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site