X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fuhttpd.git;a=blobdiff_plain;f=auth.c;h=05bec66c91b26f47f8eeec74d84bc908dc853ed2;hp=da7263f7120e0daab393d56d9a88a69f4ef3fb8b;hb=b016f111233e840da8879b1fe933b72aa8ac625f;hpb=5ddf71b3638788f8d1dd1d312ec79acfac7f3e74 diff --git a/auth.c b/auth.c index da7263f..05bec66 100644 --- a/auth.c +++ b/auth.c @@ -26,6 +26,7 @@ void uh_auth_add(const char *path, const char *user, const char *pass) struct auth_realm *new = NULL; struct passwd *pwd; const char *new_pass = NULL; + char *dest_path, *dest_user, *dest_pass; #ifdef HAVE_SHADOW struct spwd *spwd; @@ -52,12 +53,16 @@ void uh_auth_add(const char *path, const char *user, const char *pass) if (!new_pass || !new_pass[0]) return; - new = calloc(1, sizeof(*new)); + new = calloc_a(sizeof(*new), + &dest_path, strlen(path) + 1, + &dest_user, strlen(user) + 1, + &dest_pass, strlen(new_pass) + 1); + if (!new) return; - snprintf(new->path, sizeof(new->path), "%s", path); - snprintf(new->user, sizeof(new->user), "%s", user); - snprintf(new->pass, sizeof(new->user), "%s", new_pass); + new->path = strcpy(dest_path, path); + new->user = strcpy(dest_user, user); + new->pass = strcpy(dest_pass, new_pass); list_add(&new->list, &auth_realms); }