summaryrefslogtreecommitdiffstats
path: root/toolbox
diff options
context:
space:
mode:
authorJohan Redestig <johan.redestig@sonymobile.com>2015-03-30 16:24:55 +0200
committerElliott Hughes <enh@google.com>2015-03-30 10:17:29 -0700
commitc06541912d344d30df51b00d646f40c7c2cdad1d (patch)
tree737c0fe81975095d4755de4bad08c63bb460c4bd /toolbox
parent934102baf8fca57abf63df7f134e977e696722db (diff)
downloadsystem_core-c06541912d344d30df51b00d646f40c7c2cdad1d.zip
system_core-c06541912d344d30df51b00d646f40c7c2cdad1d.tar.gz
system_core-c06541912d344d30df51b00d646f40c7c2cdad1d.tar.bz2
toolbox: Fixed type mismatch for ioctl(BLKGETSIZE)
ioctl(BLKGETSIZE) expects unsigned long (8 bytes on 64 bit environment). Change-Id: Ic0f1d48e1d4cb890dbf617b3eb6285425cdbf0d0
Diffstat (limited to 'toolbox')
-rw-r--r--toolbox/newfs_msdos.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/toolbox/newfs_msdos.c b/toolbox/newfs_msdos.c
index 01517fd..5b98a01 100644
--- a/toolbox/newfs_msdos.c
+++ b/toolbox/newfs_msdos.c
@@ -798,6 +798,7 @@ static void getdiskinfo(int fd, const char *fname, const char *dtype,
__unused int oflag,struct bpb *bpb)
{
struct hd_geometry geom;
+ u_long block_size;
if (ioctl(fd, BLKSSZGET, &bpb->bps)) {
fprintf(stderr, "Error getting bytes / sector (%s)\n", strerror(errno));
@@ -806,11 +807,18 @@ static void getdiskinfo(int fd, const char *fname, const char *dtype,
ckgeom(fname, bpb->bps, "bytes/sector");
- if (ioctl(fd, BLKGETSIZE, &bpb->bsec)) {
+ if (ioctl(fd, BLKGETSIZE, &block_size)) {
fprintf(stderr, "Error getting blocksize (%s)\n", strerror(errno));
exit(1);
}
+ if (block_size > UINT32_MAX) {
+ fprintf(stderr, "Error blocksize too large: %lu\n", block_size);
+ exit(1);
+ }
+
+ bpb->bsec = (u_int)block_size;
+
if (ioctl(fd, HDIO_GETGEO, &geom)) {
fprintf(stderr, "Error getting gemoetry (%s) - trying sane values\n", strerror(errno));
geom.heads = 64;