aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2006-03-12 23:12:31 -0800
committerH. Peter Anvin <hpa@zytor.com>2006-03-12 23:12:31 -0800
commit19c3071fc36baa7903e567d2e8bb8ce5c8a206cb (patch)
treefa80d8cc57ed34bca3c1c556bb8b013df62809b1
parent7a3728f1058a791118628ecc372fd3155ee3ec5e (diff)
downloadklibc-19c3071fc36baa7903e567d2e8bb8ce5c8a206cb.tar.gz
Enforce 64-bit alignment on the data bufferklibc-1.2.5
(Reported by Fabio Di Nitto)
-rw-r--r--usr/kinit/fstype/fstype.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/usr/kinit/fstype/fstype.c b/usr/kinit/fstype/fstype.c
index a897e588cec04..370d6ca2cc139 100644
--- a/usr/kinit/fstype/fstype.c
+++ b/usr/kinit/fstype/fstype.c
@@ -52,16 +52,20 @@
/* Swap needs the definition of block size */
#include "swap_fs.h"
-static int gzip_image(const unsigned char *buf, unsigned long long *bytes)
+static int gzip_image(const void *buf, unsigned long long *bytes)
{
- if (buf[0] == 037 && (buf[1] == 0213 || buf[1] == 0236)) {
- *bytes = 0; /* Can only be determined by processing the whole file */
+ const unsigned char *p = buf;
+
+ if (p[0] == 037 && (p[1] == 0213 || p[1] == 0236)) {
+ /* The length of a gzip stream can only be determined
+ by processing the whole stream */
+ *bytes = 0ULL;
return 1;
}
return 0;
}
-static int cramfs_image(const unsigned char *buf, unsigned long long *bytes)
+static int cramfs_image(const void *buf, unsigned long long *bytes)
{
const struct cramfs_super *sb =
(const struct cramfs_super *)buf;
@@ -76,7 +80,7 @@ static int cramfs_image(const unsigned char *buf, unsigned long long *bytes)
return 0;
}
-static int romfs_image(const unsigned char *buf, unsigned long long *bytes)
+static int romfs_image(const void *buf, unsigned long long *bytes)
{
const struct romfs_super_block *sb =
(const struct romfs_super_block *)buf;
@@ -88,7 +92,7 @@ static int romfs_image(const unsigned char *buf, unsigned long long *bytes)
return 0;
}
-static int minix_image(const unsigned char *buf, unsigned long long *bytes)
+static int minix_image(const void *buf, unsigned long long *bytes)
{
const struct minix_super_block *sb =
(const struct minix_super_block *)buf;
@@ -102,7 +106,7 @@ static int minix_image(const unsigned char *buf, unsigned long long *bytes)
return 0;
}
-static int ext3_image(const unsigned char *buf, unsigned long long *bytes)
+static int ext3_image(const void *buf, unsigned long long *bytes)
{
const struct ext3_super_block *sb =
(const struct ext3_super_block *)buf;
@@ -116,7 +120,7 @@ static int ext3_image(const unsigned char *buf, unsigned long long *bytes)
return 0;
}
-static int ext2_image(const unsigned char *buf, unsigned long long *bytes)
+static int ext2_image(const void *buf, unsigned long long *bytes)
{
const struct ext2_super_block *sb =
(const struct ext2_super_block *)buf;
@@ -129,7 +133,7 @@ static int ext2_image(const unsigned char *buf, unsigned long long *bytes)
return 0;
}
-static int reiserfs_image(const unsigned char *buf, unsigned long long *bytes)
+static int reiserfs_image(const void *buf, unsigned long long *bytes)
{
const struct reiserfs_super_block *sb =
(const struct reiserfs_super_block *)buf;
@@ -147,7 +151,7 @@ static int reiserfs_image(const unsigned char *buf, unsigned long long *bytes)
return 0;
}
-static int xfs_image(const unsigned char *buf, unsigned long long *bytes)
+static int xfs_image(const void *buf, unsigned long long *bytes)
{
const struct xfs_sb *sb =
(const struct xfs_sb *)buf;
@@ -160,7 +164,7 @@ static int xfs_image(const unsigned char *buf, unsigned long long *bytes)
return 0;
}
-static int jfs_image(const unsigned char *buf, unsigned long long *bytes)
+static int jfs_image(const void *buf, unsigned long long *bytes)
{
const struct jfs_superblock *sb =
(const struct jfs_superblock *)buf;
@@ -172,7 +176,7 @@ static int jfs_image(const unsigned char *buf, unsigned long long *bytes)
return 0;
}
-static int luks_image(const unsigned char *buf, unsigned long long *blocks)
+static int luks_image(const void *buf, unsigned long long *blocks)
{
const struct luks_partition_header *lph =
(const struct luks_partition_header *)buf;
@@ -185,7 +189,7 @@ static int luks_image(const unsigned char *buf, unsigned long long *blocks)
return 0;
}
-static int swap_image(const unsigned char *buf, unsigned long long *blocks)
+static int swap_image(const void *buf, unsigned long long *blocks)
{
const struct swap_super_block *ssb =
(const struct swap_super_block *)buf;
@@ -201,7 +205,7 @@ static int swap_image(const unsigned char *buf, unsigned long long *blocks)
struct imagetype {
off_t block;
const char name[12];
- int (*identify)(const unsigned char *, unsigned long long *);
+ int (*identify)(const void *, unsigned long long *);
};
static struct imagetype images[] = {
@@ -223,7 +227,7 @@ static struct imagetype images[] = {
int identify_fs(int fd, const char **fstype,
unsigned long long *bytes, off_t offset)
{
- unsigned char buf[BLOCK_SIZE];
+ uint64_t buf[BLOCK_SIZE>>3]; /* 64-bit worst case alignment */
off_t cur_block = (off_t)-1;
struct imagetype *ip;
int ret;