]> arthur.barton.de Git - netatalk.git/commitdiff
Remove lenght limitation of options like "valid users"
authorRalph Boehme <sloowfranklin@gmail.com>
Fri, 23 Nov 2012 09:23:27 +0000 (10:23 +0100)
committerRalph Boehme <sloowfranklin@gmail.com>
Fri, 23 Nov 2012 09:23:27 +0000 (10:23 +0100)
The options "valid users", "rolist" and others use the function
accessvol() for parsing the options string. accessfull uses
a static buffer limited to MAXPATHLEN which limits the maximum
length of these options.

Fix this by using a strdup()ed buffer instead.

Fixes bug #473.

libatalk/util/netatalk_conf.c

index 067ed45436781e08d38b23bd24518d1b96c12f55..36fdfbedb310626afc2653505639774d4efa7e78 100644 (file)
@@ -411,26 +411,31 @@ static char *volxlate(const AFPObj *obj,
  */
 static int accessvol(const AFPObj *obj, const char *args, const char *name)
 {
-    char buf[MAXPATHLEN + 1], *p;
+    EC_INIT;
+    char *names = NULL, *p;
     struct group *gr;
 
     if (!args)
-        return -1;
+        EC_EXIT_STATUS(-1);
 
-    strlcpy(buf, args, sizeof(buf));
-    if ((p = strtok(buf, ",")) == NULL) /* nothing, return okay */
-        return -1;
+    EC_NULL_LOG( names = strdup(args) );
+
+    if ((p = strtok(names, ",")) == NULL) /* nothing, return okay */
+        EC_EXIT_STATUS(-1);
 
     while (p) {
         if (*p == '@') { /* it's a group */
             if ((gr = getgrnam(p + 1)) && gmem(gr->gr_gid, obj->ngroups, obj->groups))
-                return 1;
+                EC_EXIT_STATUS(1);
         } else if (strcasecmp(p, name) == 0) /* it's a user name */
-            return 1;
+            EC_EXIT_STATUS(1);
         p = strtok(NULL, ", ");
     }
 
-    return 0;
+EC_CLEANUP:
+    if (names)
+        free(names);
+    EC_EXIT;
 }
 
 static int hostaccessvol(const AFPObj *obj, const char *volname, const char *args)