From 9f3fb96df7232b8652d92ce7969acc039dbef126 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Tue, 5 Nov 2013 10:57:17 +0100 Subject: [PATCH] Fix a bug where only the first configured UAM was loaded Caused by strtok() not being async signal safe, use strtok_r() instead. Fixes bug #537. --- etc/afpd/auth.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/etc/afpd/auth.c b/etc/afpd/auth.c index f04404ed..b4adf555 100644 --- a/etc/afpd/auth.c +++ b/etc/afpd/auth.c @@ -1020,7 +1020,7 @@ int auth_register(const int type, struct uam_obj *uam) /* load all of the modules */ int auth_load(AFPObj *obj, const char *path, const char *list) { - char name[MAXPATHLEN + 1], buf[MAXPATHLEN + 1], *p; + char name[MAXPATHLEN + 1], buf[MAXPATHLEN + 1], *p, *last; struct uam_mod *mod; struct stat st; size_t len; @@ -1028,8 +1028,10 @@ int auth_load(AFPObj *obj, const char *path, const char *list) if (!path || !*path || !list || (len = strlen(path)) > sizeof(name) - 2) return -1; + LOG(log_debug, logtype_afpd, "auth_load: %s, %s", path, list); + strlcpy(buf, list, sizeof(buf)); - if ((p = strtok(buf, ", ")) == NULL) + if ((p = strtok_r(buf, ", ", &last)) == NULL) return -1; strcpy(name, path); @@ -1054,7 +1056,7 @@ int auth_load(AFPObj *obj, const char *path, const char *list) } else { LOG(log_info, logtype_afpd, "uam: uam not found (status=%d)", stat(name, &st)); } - p = strtok(NULL, ", "); + p = strtok_r(NULL, ", ", &last); } return 0; -- 2.39.2