projects
/
project
/
uhttpd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
88dc4e3
)
use the new calloc_a function from libubox
author
Felix Fietkau
<nbd@openwrt.org>
Mon, 31 Dec 2012 14:28:17 +0000
(15:28 +0100)
committer
Felix Fietkau
<nbd@openwrt.org>
Mon, 31 Dec 2012 14:28:17 +0000
(15:28 +0100)
auth.c
patch
|
blob
|
history
uhttpd.h
patch
|
blob
|
history
diff --git
a/auth.c
b/auth.c
index da7263f7120e0daab393d56d9a88a69f4ef3fb8b..05bec66c91b26f47f8eeec74d84bc908dc853ed2 100644
(file)
--- 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;
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;
#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;
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;
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);
}
list_add(&new->list, &auth_realms);
}
diff --git
a/uhttpd.h
b/uhttpd.h
index c023affed9f9f3d0e68d98f1b78ef19338e5171e..1e487f8ab526eeb05431ece86e079e34dad23f42 100644
(file)
--- a/
uhttpd.h
+++ b/
uhttpd.h
@@
-28,6
+28,7
@@
#include <libubox/uloop.h>
#include <libubox/ustream.h>
#include <libubox/blob.h>
#include <libubox/uloop.h>
#include <libubox/ustream.h>
#include <libubox/blob.h>
+#include <libubox/utils.h>
#include "utils.h"
#include "utils.h"
@@
-52,9
+53,9
@@
struct config {
struct auth_realm {
struct list_head list;
struct auth_realm {
struct list_head list;
- char
path[PATH_MAX]
;
- char
user[32]
;
- char
pass[128]
;
+ char
*path
;
+ char
*user
;
+ char
*pass
;
};
enum http_method {
};
enum http_method {