summaryrefslogtreecommitdiff
path: root/lib/modechange.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2000-01-12 06:49:59 +0000
committerJim Meyering <jim@meyering.net>2000-01-12 06:49:59 +0000
commit551ab8474b497fe89f60a6d9d078c0cc6eeeaa8c (patch)
tree39eb4e7592f29921be08491d270e5a3627f81204 /lib/modechange.c
parent12d6e4b1cdfc8b30585597b9beb210ee8fa54c4c (diff)
downloadcoreutils-551ab8474b497fe89f60a6d9d078c0cc6eeeaa8c.tar.xz
(mode_compile): Use uintmax_t, not unsigned
long, to parse numeric modes. Check for any unknown bits, not just unknown bits left of the leftmost known bit.
Diffstat (limited to 'lib/modechange.c')
-rw-r--r--lib/modechange.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/modechange.c b/lib/modechange.c
index 71432fa42..fda84c90a 100644
--- a/lib/modechange.c
+++ b/lib/modechange.c
@@ -1,5 +1,5 @@
/* modechange.c -- file mode manipulation
- Copyright (C) 1989, 1990, 1997, 1998, 1999 Free Software Foundation, Inc.
+ Copyright (C) 1989, 1990, 1997-2000 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -157,7 +157,7 @@ mode_compile (const char *mode_string, unsigned int masked_ops)
{
struct mode_change *head; /* First element of the linked list. */
struct mode_change *tail; /* An element of the linked list. */
- unsigned long mode_value; /* The mode value, if octal. */
+ uintmax_t mode_value; /* The mode value, if octal. */
char *string_end; /* Pointer to end of parsed value. */
mode_t umask_value; /* The umask value (surprise). */
@@ -166,10 +166,10 @@ mode_compile (const char *mode_string, unsigned int masked_ops)
tail = NULL;
#endif
- if (xstrtoul (mode_string, &string_end, 8, &mode_value, "") == LONGINT_OK)
+ if (xstrtoumax (mode_string, &string_end, 8, &mode_value, "") == LONGINT_OK)
{
struct mode_change *p;
- if (mode_value > CHMOD_MODE_BITS)
+ if (mode_value != (mode_value & CHMOD_MODE_BITS))
return MODE_INVALID;
p = make_node_op_equals ((mode_t) mode_value);
if (p == NULL)