summaryrefslogtreecommitdiff
path: root/extras
diff options
context:
space:
mode:
authorPeter Breitenlohner <peb@mppmu.mpg.de>2008-11-23 17:22:32 +0100
committerKay Sievers <kay.sievers@vrfy.org>2008-11-23 17:22:32 +0100
commit013332b93c880692e51d1056528c805fd7e4a882 (patch)
treefc46ee2ea594b515748e10f8b3f6f95e92891140 /extras
parent6733f60178cc67d5064583d433335ce8fb25eae1 (diff)
floppy: fix array bounds check and minor calculation
Fix off-by-4 bug in floppy minors for fd[4-7]. Avoid segmentation fault for bad CMOS type. Print mode in human readable, i.e., octal form.
Diffstat (limited to 'extras')
-rw-r--r--extras/floppy/create_floppy_devices.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/extras/floppy/create_floppy_devices.c b/extras/floppy/create_floppy_devices.c
index f5069f7220..14df052cf7 100644
--- a/extras/floppy/create_floppy_devices.c
+++ b/extras/floppy/create_floppy_devices.c
@@ -130,14 +130,14 @@ int main(int argc, char **argv)
return 1;
}
if (fdnum > 3)
- fdnum += 128;
+ fdnum += 124;
if (major < 1) {
fprintf(stderr,"Invalid major number %d\n", major);
return 1;
}
- if (type < 0 || type > (int) sizeof(table)) {
+ if (type < 0 || type >= (int) (sizeof(table_sup) / sizeof(table_sup[0]))) {
fprintf(stderr,"Invalid CMOS type %d\n", type);
return 1;
}
@@ -150,7 +150,7 @@ int main(int argc, char **argv)
sprintf(node, "%s%s", dev, table[table_sup[type][i]]);
minor = (table_sup[type][i] << 2) + fdnum;
if (print_nodes)
- printf("%s b %d %d %d\n", node, mode, major, minor);
+ printf("%s b %.4o %d %d\n", node, mode, major, minor);
if (create_nodes) {
unlink(node);
udev_selinux_setfscreatecon(udev, node, S_IFBLK | mode);