[PATCH] fix cramfsck segfault
Hi,
some parameters to the function die() are passed in the wrong order if
decompression fails. This leads to a segmentation fault. The attached
patch fixes that and adds a gcc attribute to prevent similar bugs.
Regards,
Andreas
--- cramfsck.c.orig 2005-09-23 19:16:30.782035600 +0200
+++ cramfsck.c 2005-09-23 19:17:20.837426024 +0200
@@ -116,7 +116,7 @@
exit(status);
}
-static void die(int status, int syserr, const char *fmt, ...)
+static void __attribute__((__format__(__printf__,3,4))) die(int status, int syserr, const char *fmt, ...)
{
va_list arg_ptr;
int save = errno;
@@ -356,7 +356,7 @@
err = inflate(&stream, Z_FINISH);
if (err != Z_STREAM_END) {
die(FSCK_UNCORRECTED, 0, "decompression error %p(%d): %s",
- zError(err), src, len);
+ src, len, zError(err));
}
return stream.total_out;
}
@@ -643,7 +643,7 @@
inflateEnd(&stream);
if (start_data != ~0UL) {
if (start_data < (sizeof(struct cramfs_super) + start)) {
- die(FSCK_UNCORRECTED, 0, "directory data start (%ld) < sizeof(struct cramfs_super) + start (%ld)", start_data, sizeof(struct cramfs_super) + start);
+ die(FSCK_UNCORRECTED, 0, "directory data start (%ld) < sizeof(struct cramfs_super) + start (%u)", start_data, sizeof(struct cramfs_super) + start);
}
if (end_dir != start_data) {
die(FSCK_UNCORRECTED, 0, "directory data end (%ld) != file data start (%ld)", end_dir, start_data);
Reply to: