From 0fab5d1cb0e4c0f5539bf60072bd120c236a9233 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Fri, 23 Nov 2012 10:23:27 +0100 Subject: [PATCH 1/1] Remove lenght limitation of options like "valid users" 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 | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/libatalk/util/netatalk_conf.c b/libatalk/util/netatalk_conf.c index 067ed454..36fdfbed 100644 --- a/libatalk/util/netatalk_conf.c +++ b/libatalk/util/netatalk_conf.c @@ -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) -- 2.39.2