setcifsacl: fix infinite loop in getnumcaces
authorJeff Layton <jlayton@samba.org>
Tue, 29 Jan 2013 02:38:12 +0000 (21:38 -0500)
committerJeff Layton <jlayton@samba.org>
Tue, 29 Jan 2013 02:38:12 +0000 (21:38 -0500)
Jian pointed out that this loop can cycle infinitely when the string
contains a ','.

Also, fix typo in manpage that shows a trailing ',' in one example.

Reported-by: Jian Li <jiali@redhat.com>
Signed-off-by: Jeff Layton <jlayton@samba.org>
setcifsacl.1.in
setcifsacl.c

index 5ede36ad4050183589cc67bf226bb8d91d17504b..d53a6ec9a5b2448e1f16b61b81780f80a70f68e9 100644 (file)
@@ -94,7 +94,7 @@ Set an ACL
 .br
 setcifsacl -S "ACL:CIFSTESTDOM\\Administrator:0x0/0x0/FULL,
 .br
-ACL:CIFSTESTDOM\\user2:0x0/0x0/FULL," <file_name>
+ACL:CIFSTESTDOM\\user2:0x0/0x0/FULL" <file_name>
 .PP
 .SH "NOTES"
 .PP
index 211c1af35e0bf8c812826c6d47200e0ff2c8b394..7f92b91ff063adddd0878a06c62c379c5653aca3 100644 (file)
@@ -642,8 +642,10 @@ get_numcaces(const char *aces)
        const char *current;
 
        current = aces;
-       while((current = strchr(current, ',')))
+       while((current = strchr(current, ','))) {
+               ++current;
                ++num;
+       }
 
        return num;
 }