diff options
author | Pedro Martelletto <pedro@cvs.openbsd.org> | 2007-04-09 20:22:42 +0000 |
---|---|---|
committer | Pedro Martelletto <pedro@cvs.openbsd.org> | 2007-04-09 20:22:42 +0000 |
commit | b77de0322bb373112a4d0b239571875c9e07e9be (patch) | |
tree | d2988b2c01827ad28c2294c5f9fd7e9a382b030c /sbin/mount_ntfs | |
parent | e515e43c91d2bebfc1e01aa1063d1b20fa538415 (diff) |
Correctly handle option '-m', okay mickey@ grunk@
Diffstat (limited to 'sbin/mount_ntfs')
-rw-r--r-- | sbin/mount_ntfs/mount_ntfs.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/sbin/mount_ntfs/mount_ntfs.c b/sbin/mount_ntfs/mount_ntfs.c index 4e17130d29f..c223e187bf6 100644 --- a/sbin/mount_ntfs/mount_ntfs.c +++ b/sbin/mount_ntfs/mount_ntfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mount_ntfs.c,v 1.10 2006/12/15 12:53:59 jmc Exp $ */ +/* $OpenBSD: mount_ntfs.c,v 1.11 2007/04/09 20:22:41 pedro Exp $ */ /* $NetBSD: mount_ntfs.c,v 1.9 2003/05/03 15:37:08 christos Exp $ */ /* @@ -65,6 +65,7 @@ static const struct mntopt mopts[] = { #endif static void usage(void) __dead2; +mode_t a_mask(char *); int main(int, char **); int @@ -89,7 +90,7 @@ main(int argc, char *argv[]) set_gid = 1; break; case 'm': - args.mode = atoi(optarg); + args.mode = a_mask(optarg); set_mask = 1; break; case 'i': @@ -146,6 +147,22 @@ main(int argc, char *argv[]) exit (0); } +mode_t +a_mask(char *s) +{ + int done, rv; + char *ep; + + done = 0; + if (*s >= '0' && *s <= '7') { + done = 1; + rv = strtol(optarg, &ep, 8); + } + if (!done || rv < 0 || *ep) + errx(1, "invalid file mode: %s", s); + return (rv); +} + static void usage(void) { |