Add Gnulib module xalloc

This commit is contained in:
wbaumann 2012-01-28 19:54:55 +00:00
parent 828ded4558
commit 6559f12463
7 changed files with 103 additions and 107 deletions

View File

@ -10,6 +10,8 @@ ChangeLog for davfs2
Use getgroups.
* mount_davfs.c, check_dirs, read_secrets:
Check secrets file in check_dirs.
* all:
Add Gnulib module xalloc.

2012-01-25 Werner Baumann (werner.baumann@onlinehome.de)
* mount_davfs.c, mount_davfs.h:

View File

@ -15,7 +15,7 @@


# Specification in the form of a command-line invocation:
# gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=config --po-base=glpo --doc-base=doc --tests-base=tests --aux-dir=config --no-libtool --macro-prefix=gl --po-domain=davfs2 canonicalize iconv_open rpmatch
# gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=config --po-base=glpo --doc-base=doc --tests-base=tests --aux-dir=config --no-libtool --macro-prefix=gl --po-domain=davfs2 canonicalize iconv_open rpmatch xalloc

# Specification in the form of a few gnulib-tool.m4 macro invocations:
gl_LOCAL_DIR([])
@ -23,6 +23,7 @@ gl_MODULES([
canonicalize
iconv_open
rpmatch
xalloc
])
gl_AVOID([])
gl_SOURCE_BASE([gl])

View File

@ -59,6 +59,8 @@
#endif
#include <sys/xattr.h>

#include "xalloc.h"

#include <ne_alloc.h>
#include <ne_string.h>
#include <ne_xml.h>
@ -600,7 +602,7 @@ dav_init_cache(const dav_args *args, const char *mpoint)
dir_umask = args->dir_umask;

table_size = args->table_size;
table = ne_calloc(sizeof(*table) * table_size);
table = xcalloc(table_size, sizeof(*table));

dir_refresh = args->dir_refresh;
file_refresh = args->file_refresh;
@ -612,8 +614,7 @@ dav_init_cache(const dav_args *args, const char *mpoint)
max_upload_attempts = args->max_upload_attempts;
lock_refresh = args->lock_refresh;

fs_stat = (dav_stat *) malloc(sizeof(dav_stat));
if (!fs_stat) abort();
fs_stat = (dav_stat *) xmalloc(sizeof(dav_stat));

fs_stat->blocks = 0x65B9AA;
fs_stat->bfree = 0x32DCD5;
@ -640,13 +641,13 @@ dav_init_cache(const dav_args *args, const char *mpoint)
if (debug)
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "Reading stored cache data");
parse_index();
root->name = ne_strdup("");
root->name = xstrdup("");
root->path = dav_conv_to_server_enc(args->path);
root->mode = default_dir_mode;

if (!backup)
backup = new_node(root, S_IFDIR | S_IRWXU);
backup->name = ne_strdup(args->backup_dir);
backup->name = xstrdup(args->backup_dir);
backup->mode = S_IFDIR | S_IRWXU;

clean_cache();
@ -929,7 +930,7 @@ dav_create(dav_node **nodep, dav_node *parent, const char *name, uid_t uid,

*nodep = new_node(parent, mode | S_IFREG);
(*nodep)->path = path;
(*nodep)->name = ne_strdup(name);
(*nodep)->name = xstrdup(name);
(*nodep)->uid = uid;
(*nodep)->gid = pw->pw_gid;
int ret = create_cache_file(*nodep);
@ -1108,7 +1109,7 @@ dav_mkdir(dav_node **nodep, dav_node *parent, const char *name, uid_t uid,
if (!ret) {
*nodep = new_node(parent, mode | S_IFDIR);
(*nodep)->path = path;
(*nodep)->name = ne_strdup(name);
(*nodep)->name = xstrdup(name);
(*nodep)->uid = uid;
(*nodep)->gid = pw->pw_gid;
(*nodep)->smtime = (*nodep)->mtime;
@ -1680,9 +1681,7 @@ add_to_changed(dav_node *node)
return;
chp = &(*chp)->next;
}
*chp = (dav_node_list_item *) malloc(sizeof(dav_node_list_item));
if (!*chp)
abort();
*chp = (dav_node_list_item *) xmalloc(sizeof(dav_node_list_item));
(*chp)->node = node;
(*chp)->next = NULL;
(*chp)->attempts = 0;
@ -1702,7 +1701,7 @@ backup_node(dav_node *orig)
if (!orig->cache_path)
return;
dav_node *node = new_node(backup, orig->mode);
node->name = ne_strdup(orig->cache_path + strlen(cache_dir) +1);
node->name = xstrdup(orig->cache_path + strlen(cache_dir) +1);
node->cache_path = orig->cache_path;
orig->cache_path = NULL;
node->mime_type = orig->mime_type;
@ -1863,7 +1862,7 @@ move_dir(dav_node *src, dav_node *dst, dav_node *dst_parent,
dst_path = ne_concat(dst_parent->path, dst_conv, "/", NULL);
free(dst_conv);
} else {
dst_path = ne_strdup(dst->path);
dst_path = xstrdup(dst->path);
}

if (dav_move(src->path, dst_path) != 0) {
@ -1875,7 +1874,7 @@ move_dir(dav_node *src, dav_node *dst, dav_node *dst_parent,
remove_node(dst);

free(src->name);
src->name = ne_strdup(dst_name);
src->name = xstrdup(dst_name);
update_path(src, src->path, dst_path);
free(dst_path);

@ -1902,7 +1901,7 @@ move_no_remote(dav_node *src, dav_node *dst, dav_node *dst_parent,
dst_path = ne_concat(dst_parent->path, dst_conv, NULL);
free(dst_conv);
} else {
dst_path = ne_strdup(dst->path);
dst_path = xstrdup(dst->path);
}

if (dst) {
@ -1941,7 +1940,7 @@ move_no_remote(dav_node *src, dav_node *dst, dav_node *dst_parent,
dav_set_execute(dst_path, 1);

free(src->name);
src->name = ne_strdup(dst_name);
src->name = xstrdup(dst_name);
free(src->path);
src->path = dst_path;
if (src->etag) {
@ -1972,7 +1971,7 @@ move_reg(dav_node *src, dav_node *dst, dav_node *dst_parent,
dst_path = ne_concat(dst_parent->path, dst_conv, NULL);
free(dst_conv);
} else {
dst_path = ne_strdup(dst->path);
dst_path = xstrdup(dst->path);
}

if (dav_move(src->path, dst_path) != 0) {
@ -2002,7 +2001,7 @@ move_reg(dav_node *src, dav_node *dst, dav_node *dst_parent,
}

free(src->name);
src->name = ne_strdup(dst_name);
src->name = xstrdup(dst_name);
free(src->path);
src->path = dst_path;
src->utime = time(NULL);
@ -2022,7 +2021,7 @@ move_reg(dav_node *src, dav_node *dst, dav_node *dst_parent,
static dav_node *
new_node(dav_node *parent, mode_t mode)
{
dav_node *node = (dav_node *) ne_malloc(sizeof(dav_node));
dav_node *node = (dav_node *) xmalloc(sizeof(dav_node));

node->parent = parent;
node->childs = NULL;
@ -2297,7 +2296,7 @@ update_node(dav_node *node, dav_props *props)

if (strcmp(node->name, props->name) != 0) {
free(node->name);
node->name = ne_strdup(props->name);
node->name = xstrdup(props->name);
ret = 1;
*flush = 1;
}
@ -2630,7 +2629,7 @@ open_file(int *fd, dav_node *node, int flags, pid_t pid, pid_t pgid, uid_t uid)
*fd = open(node->cache_path, flags, node->mode);
if (*fd <= 0)
return EIO;
dav_handle *fh = (dav_handle *) ne_malloc(sizeof(dav_handle));
dav_handle *fh = (dav_handle *) xmalloc(sizeof(dav_handle));
fh->fd = *fd;
fh->flags = O_ACCMODE & flags;
fh->pid = pid;
@ -2854,7 +2853,7 @@ clean_cache(void)
dav_node *found = new_node(backup, default_file_mode);
found->mode &= ~(S_IRWXG | S_IRWXO);
found->cache_path = path;
found->name = ne_strdup(de->d_name);
found->name = xstrdup(de->d_name);
attr_from_cache_file(found);
backup->mtime = time(NULL);
backup->ctime = backup->mtime;
@ -2884,7 +2883,7 @@ parse_index(void)
return;
}

char *buf = ne_malloc(DAV_XML_BUF_SIZE);
char *buf = xmalloc(DAV_XML_BUF_SIZE);
size_t len = fread(buf, 1, DAV_XML_BUF_SIZE, idx);
if (len <= 0) {
free(buf);
@ -3780,8 +3779,8 @@ test_alignment()

size_t j = 0;
while (align > 0 && j < trials) {
s[j] = (char *) ne_malloc((rand() / (RAND_MAX / 1024)) % (4 *align));
n[j] = (dav_node *) ne_malloc(sizeof(dav_node));
s[j] = (char *) xmalloc((rand() / (RAND_MAX / 1024)) % (4 *align));
n[j] = (dav_node *) xmalloc(sizeof(dav_node));
while (align > 0 && ((size_t) n[j] % align) > 0)
align /= 2;
++j;

View File

@ -54,6 +54,8 @@
#include <sys/stat.h>
#endif

#include "xalloc.h"

#include "defaults.h"
#include "mount_davfs.h"
#include "cache.h"
@ -100,8 +102,7 @@ dav_init_kernel_interface(int *dev, dav_run_msgloop_fn *msg_loop, void **mdata,
const char *mpoint, const dav_args *args)
{
if (!*kernel_fs)
*kernel_fs = strdup("fuse");
if (!*kernel_fs) abort();
*kernel_fs = xstrdup("fuse");

int mounted = 0;
if (strcmp(*kernel_fs, "coda") == 0) {
@ -112,8 +113,7 @@ dav_init_kernel_interface(int *dev, dav_run_msgloop_fn *msg_loop, void **mdata,
args->mopts, args->fsuid, args->fsgid, args->dir_mode)
== 0) {
free(*kernel_fs);
*kernel_fs = strdup("fuse");
if (!*kernel_fs) abort();
*kernel_fs = xstrdup("fuse");
mounted = 1;
error(0, 0, _("fuse device opened successfully"));
} else {
@ -130,9 +130,7 @@ dav_init_kernel_interface(int *dev, dav_run_msgloop_fn *msg_loop, void **mdata,
error(0, 0, _("trying coda kernel file system"));
if (init_coda(dev, msg_loop, mdata) == 0) {
free(*kernel_fs);
*kernel_fs = strdup("coda");
if (*kernel_fs == NULL)
abort();
*kernel_fs = xstrdup("coda");
error(0, 0, _("coda device opened successfully"));
} else {
exit(EXIT_FAILURE);
@ -203,8 +201,7 @@ init_coda(int *dev, dav_run_msgloop_fn *msg_loop, void **mdata)
return -1;
}

struct coda_mount_data *md = malloc(sizeof(struct coda_mount_data));
if (!md) abort();
struct coda_mount_data *md = xmalloc(sizeof(struct coda_mount_data));
md->version = CODA_MOUNT_VERSION;
md->fd = *dev;
*mdata = md;

View File

@ -69,12 +69,14 @@
#include <sys/types.h>
#endif

#include "canonicalize.h"
#include "xalloc.h"

#include <ne_string.h>
#include <ne_uri.h>
#include <ne_utils.h>

#include "defaults.h"
#include "canonicalize.h"
#include "mount_davfs.h"
#include "kernel_interface.h"
#include "cache.h"
@ -268,7 +270,7 @@ main(int argc, char *argv[])
dav_run_msgloop_fn run_msgloop = NULL;
void *mdata = NULL;
if (args->kernel_fs)
kernel_fs = ne_strdup(args->kernel_fs);
kernel_fs = xstrdup(args->kernel_fs);
size_t buf_size = args->buf_size * 1024;
gain_privileges(args);
int mounted = dav_init_kernel_interface(&dev, &run_msgloop, &mdata,
@ -650,7 +652,7 @@ check_double_mounts(dav_args *args)
char *m = mpoint;
while (*m == '/')
m++;
char *mp = ne_strdup(m);
char *mp = xstrdup(m);
m = strchr(mp, '/');
while (m) {
*m = '-';
@ -882,8 +884,7 @@ parse_commandline(dav_args *args, int argc, char *argv[])
int i;
for (i = 0; i < argc; i++)
len += strlen(argv[i]);
args->cmdline = malloc(len);
if (!args->cmdline) abort();
args->cmdline = xmalloc(len);
char *p = args->cmdline;
for (i = 0; i < argc - 1; i++) {
strcpy(p, argv[i]);
@ -939,7 +940,7 @@ parse_commandline(dav_args *args, int argc, char *argv[])
if (*argv[i] == '\"' || *argv[i] == '\'') {
url = ne_strndup(argv[i] + 1, strlen(argv[i]) -2);
} else {
url = ne_strdup(argv[i]);
url = xstrdup(argv[i]);
}
i++;
mpoint = canonicalize_file_name(argv[i]);
@ -1002,7 +1003,7 @@ parse_config(dav_args *args)
read_config(args, args->conf, 0);

if (!args->dav_user)
args->dav_user = ne_strdup(DAV_USER);
args->dav_user = xstrdup(DAV_USER);
struct passwd *pw = getpwnam(args->dav_user);
if (!pw)
error(EXIT_FAILURE, errno, _("user %s does not exist"),
@ -1010,7 +1011,7 @@ parse_config(dav_args *args)
args->dav_uid = pw->pw_uid;

if (!args->dav_group)
args->dav_group = ne_strdup(DAV_GROUP);
args->dav_group = xstrdup(DAV_GROUP);
struct group *grp = getgrnam(args->dav_group);
if (!grp)
error(EXIT_FAILURE, errno, _("group %s does not exist"),
@ -1089,9 +1090,9 @@ parse_config(dav_args *args)
args->useproxy = 0;

if (!args->sys_cache)
args->sys_cache = ne_strdup(DAV_SYS_CACHE);
args->sys_cache = xstrdup(DAV_SYS_CACHE);
if (args->privileged) {
args->cache_dir = ne_strdup(args->sys_cache);
args->cache_dir = xstrdup(args->sys_cache);
} else {
if (args->cache_dir) {
expand_home(&args->cache_dir, args);
@ -1102,7 +1103,7 @@ parse_config(dav_args *args)
}

if (!args->backup_dir)
args->backup_dir = ne_strdup(DAV_BACKUP_DIR);
args->backup_dir = xstrdup(DAV_BACKUP_DIR);

if (args->debug & DAV_DBG_CONFIG)
log_dbg_config(args);
@ -1129,15 +1130,13 @@ parse_persona(dav_args *args)
struct passwd *pw = getpwuid(args->uid);
if (!pw || !pw->pw_name || !pw->pw_dir)
error(EXIT_FAILURE, errno, _("can't read user data base"));
args->uid_name = strdup(pw->pw_name);
args->uid_name = xstrdup(pw->pw_name);
args->home = canonicalize_file_name(pw->pw_dir);
if (!args->uid_name || !args->home) abort();
}

args->ngroups = getgroups(0, NULL);
if (args->ngroups) {
args->groups = (gid_t *) malloc(args->ngroups * sizeof(gid_t));
if (!args->groups) abort();
args->groups = (gid_t *) xmalloc(args->ngroups * sizeof(gid_t));
if (getgroups(args->ngroups, args->groups) < 0)
error(EXIT_FAILURE, 0, _("can't read group data base"));
}
@ -1625,12 +1624,12 @@ get_options(dav_args *args, char *option)
case CONF:
if (args->conf)
free(args->conf);
args->conf = ne_strdup(argument);
args->conf = xstrdup(argument);
break;
case USERNAME:
if (args->cl_username)
free(args->cl_username);
args->cl_username = ne_strdup(argument);
args->cl_username = xstrdup(argument);
break;
case UID:
pwd = getpwnam(argument);
@ -1734,8 +1733,7 @@ get_options(dav_args *args, char *option)
static dav_args *
new_args(void)
{
dav_args *args = (dav_args *) calloc(1, sizeof(dav_args));
if (!args) abort();
dav_args *args = (dav_args *) xcalloc(1, sizeof(dav_args));

args->netdev = DAV_NETDEV;
args->mopts = DAV_USER_MOPTS;
@ -2107,29 +2105,29 @@ read_config(dav_args *args, const char * filename, int system)
if (system && strcmp(parmv[0], "dav_user") == 0) {
if (args->dav_user)
free(args->dav_user);
args->dav_user = ne_strdup(parmv[1]);
args->dav_user = xstrdup(parmv[1]);
} else if (system && strcmp(parmv[0], "dav_group") == 0) {
if (args->dav_group)
free(args->dav_group);
args->dav_group = ne_strdup(parmv[1]);
args->dav_group = xstrdup(parmv[1]);
} else if (strcmp(parmv[0], "kernel_fs") == 0) {
if (args->kernel_fs)
free(args->kernel_fs);
args->kernel_fs = ne_strdup(parmv[1]);
args->kernel_fs = xstrdup(parmv[1]);
} else if (strcmp(parmv[0], "buf_size") == 0) {
args->buf_size = arg_to_int(parmv[1], 10, parmv[0]);
} else if (strcmp(parmv[0], "servercert") == 0) {
if (args->servercert)
free(args->servercert);
args->servercert = ne_strdup(parmv[1]);
args->servercert = xstrdup(parmv[1]);
} else if (!system && strcmp(parmv[0], "secrets") == 0) {
if (args->secrets)
free(args->secrets);
args->secrets = ne_strdup(parmv[1]);
args->secrets = xstrdup(parmv[1]);
} else if (strcmp(parmv[0], "clientcert") == 0) {
if (args->clicert)
free(args->clicert);
args->clicert = ne_strdup(parmv[1]);
args->clicert = xstrdup(parmv[1]);
} else if (system && strcmp(parmv[0], "proxy") == 0) {
if (split_uri(NULL, &args->p_host, &args->p_port, NULL,
parmv[1]) != 0)
@ -2144,7 +2142,7 @@ read_config(dav_args *args, const char * filename, int system)
} else if (strcmp(parmv[0], "lock_owner") == 0) {
if (args->lock_owner)
free(args->lock_owner);
args->lock_owner = ne_strdup(parmv[1]);
args->lock_owner = xstrdup(parmv[1]);
} else if (strcmp(parmv[0], "lock_timeout") == 0) {
args->lock_timeout = arg_to_int(parmv[1], 10, parmv[0]);
} else if (strcmp(parmv[0], "lock_refresh") == 0) {
@ -2174,19 +2172,19 @@ read_config(dav_args *args, const char * filename, int system)
} else if (strcmp(parmv[0], "server_charset") == 0) {
if (args->s_charset)
free(args->s_charset);
args->s_charset = ne_strdup(parmv[1]);
args->s_charset = xstrdup(parmv[1]);
} else if (system && strcmp(parmv[0], "cache_dir") == 0) {
if (args->sys_cache)
free(args->sys_cache);
args->sys_cache = ne_strdup(parmv[1]);
args->sys_cache = xstrdup(parmv[1]);
} else if (!system && strcmp(parmv[0], "cache_dir") == 0) {
if (args->cache_dir != NULL)
free(args->cache_dir);
args->cache_dir = ne_strdup(parmv[1]);
args->cache_dir = xstrdup(parmv[1]);
} else if (strcmp(parmv[0], "backup_dir") == 0) {
if (args->backup_dir)
free(args->backup_dir);
args->backup_dir = ne_strdup(parmv[1]);
args->backup_dir = xstrdup(parmv[1]);
} else if (strcmp(parmv[0], "cache_size") == 0) {
args->cache_size = arg_to_int(parmv[1], 10, parmv[0]);
} else if (strcmp(parmv[0], "table_size") == 0) {
@ -2254,7 +2252,7 @@ read_no_proxy_list(dav_args *args)
return;
}

char *noproxy_list = ne_strdup(env);
char *noproxy_list = xstrdup(env);
char *np = strtok(noproxy_list, ", ");
while (np && args->p_host) {

@ -2263,7 +2261,7 @@ read_no_proxy_list(dav_args *args)
if (asprintf(&host, "%s:%d", args->host, args->port) < 0)
abort();
} else {
host = strdup(args->host);
host = xstrdup(args->host);
}

if (*np == '.') {
@ -2352,9 +2350,9 @@ read_secrets(dav_args *args, const char *filename)
memset(args->password, '\0', strlen(args->password));
free(args->password);
}
args->username = ne_strdup(parmv[1]);
args->username = xstrdup(parmv[1]);
if (count == 3)
args->password = ne_strdup(parmv[2]);
args->password = xstrdup(parmv[2]);

} else if (strcmp(parmv[0], "proxy") == 0
|| (host && args->p_host
@ -2369,9 +2367,9 @@ read_secrets(dav_args *args, const char *filename)
memset(args->p_passwd, '\0', strlen(args->p_passwd));
free(args->p_passwd);
}
args->p_user = ne_strdup(parmv[1]);
args->p_user = xstrdup(parmv[1]);
if (count == 3)
args->p_passwd = ne_strdup(parmv[2]);
args->p_passwd = xstrdup(parmv[2]);

} else if (args->clicert
&& (strcmp(parmv[0], args->clicert) == 0
@ -2384,7 +2382,7 @@ read_secrets(dav_args *args, const char *filename)
memset(args->clicert_pw, '\0', strlen(args->clicert_pw));
free(args->clicert_pw);
}
args->clicert_pw = ne_strdup(parmv[1]);
args->clicert_pw = xstrdup(parmv[1]);
}

if (scheme) free(scheme);
@ -2467,11 +2465,10 @@ split_uri(char **scheme, char **host, int *port,char **path, const char *uri)
if (scheme) {
if (*scheme) free(*scheme);
if (sch) {
*scheme = strdup(sch);
*scheme = xstrdup(sch);
} else {
*scheme = strdup("http");
*scheme = xstrdup("http");
}
if (!*scheme) abort();
}

if (port && po)
@ -2479,8 +2476,7 @@ split_uri(char **scheme, char **host, int *port,char **path, const char *uri)

if (host) {
if (*host) free(*host);
*host = malloc(end - ho + 1);
if (!*host) abort();
*host = xmalloc(end - ho + 1);
int i;
for (i = 0; i < (end - ho); i++) {
if (*ho == '[') {
@ -2497,13 +2493,12 @@ split_uri(char **scheme, char **host, int *port,char **path, const char *uri)
if (path) {
if (*path) free(*path);
if (!*pa) {
*path = strdup("/");
*path = xstrdup("/");
} else if (*(pa + strlen(pa) - 1) == '/') {
*path = strdup(pa);
*path = xstrdup(pa);
} else {
if (asprintf(path, "%s/", pa) < 1) abort();
}
if (!*path) abort();
}

return 0;

View File

@ -40,6 +40,8 @@
#include <unistd.h>
#endif

#include "xalloc.h"

#include <ne_string.h>

#include "defaults.h"
@ -132,7 +134,7 @@ main(int argc, char *argv[])
char *m = mpoint;
while (*m == '/')
m++;
char *mp = ne_strdup(m);
char *mp = xstrdup(m);
m = strchr(mp, '/');
while (m) {
*m = '-';

View File

@ -56,6 +56,8 @@
#include <sys/stat.h>
#endif

#include "xalloc.h"

#include <ne_alloc.h>
#include <ne_auth.h>
#include <ne_basic.h>
@ -354,9 +356,8 @@ dav_init_webdav(const dav_args *args)
error(EXIT_FAILURE, errno, _("socket library initialization failed"));

if (args->neon_debug & ~NE_DBG_HTTPPLAIN) {
char *buf = malloc(log_bufsize);
cookie_io_functions_t *log_func = malloc(sizeof(cookie_io_functions_t));
if (!log_func) abort();
char *buf = xmalloc(log_bufsize);
cookie_io_functions_t *log_func = xmalloc(sizeof(cookie_io_functions_t));
log_func->read = NULL;
log_func->write = log_writer;
log_func->seek = NULL;
@ -381,9 +382,9 @@ dav_init_webdav(const dav_args *args)
free(useragent);

if (args->username)
username = ne_strdup(args->username);
username = xstrdup(args->username);
if (args->password)
password = ne_strdup(args->password);
password = xstrdup(args->password);
#if NE_VERSION_MINOR < 26
ne_set_server_auth(session, auth, "server");
#else /* NE_VERSION_MINOR >= 26 */
@ -393,9 +394,9 @@ dav_init_webdav(const dav_args *args)
if (args->useproxy && args->p_host) {
ne_session_proxy(session, args->p_host, args->p_port);
if (args->p_user)
p_username = ne_strdup(args->p_user);
p_username = xstrdup(args->p_user);
if (args->p_passwd)
p_password = ne_strdup(args->p_passwd);
p_password = xstrdup(args->p_passwd);
#if NE_VERSION_MINOR < 26
ne_set_proxy_auth(session, auth, "proxy");
#else /* NE_VERSION_MINOR >= 26 */
@ -435,7 +436,7 @@ dav_init_webdav(const dav_args *args)
"certificate %s.\n"), args->clicert);
pw = dav_user_input_hidden(_("Password: "));
} else {
pw = ne_strdup(args->clicert_pw);
pw = xstrdup(args->clicert_pw);
}
int ret = 1;
if (pw) {
@ -459,18 +460,18 @@ dav_init_webdav(const dav_args *args)
locks = ne_lockstore_create();
if (!args->lock_owner) {
if (!args->username) {
owner = ne_strdup(PACKAGE_STRING);
owner = xstrdup(PACKAGE_STRING);
} else {
owner = ne_strdup(args->username);
owner = xstrdup(args->username);
}
} else {
owner = ne_strdup(args->lock_owner);
owner = xstrdup(args->lock_owner);
}
lock_timeout = args->lock_timeout;
}

if (args->header) {
custom_header = ne_strdup(args->header);
custom_header = xstrdup(args->header);
ne_hook_pre_send(session, add_header, custom_header);
}

@ -550,7 +551,7 @@ dav_close_webdav(void)
char *
dav_conv_from_utf_8(const char *s)
{
char *new = ne_strdup(s);
char *new = xstrdup(s);
#if defined DAV_USE_ICONV && defined HAVE_ICONV_H
if (from_utf_8)
convert(&new, from_utf_8);
@ -562,7 +563,7 @@ dav_conv_from_utf_8(const char *s)
char *
dav_conv_to_utf_8(const char *s)
{
char *new = ne_strdup(s);
char *new = xstrdup(s);
#if defined DAV_USE_ICONV && defined HAVE_ICONV_H
if (to_utf_8)
convert(&new, to_utf_8);
@ -574,7 +575,7 @@ dav_conv_to_utf_8(const char *s)
char *
dav_conv_from_server_enc(const char *s)
{
char *new = ne_strdup(s);
char *new = xstrdup(s);
#if defined DAV_USE_ICONV && defined HAVE_ICONV_H
if (from_server_enc)
convert(&new, from_server_enc);
@ -586,7 +587,7 @@ dav_conv_from_server_enc(const char *s)
char *
dav_conv_to_server_enc(const char *s)
{
char *new = ne_strdup(s);
char *new = xstrdup(s);
#if defined DAV_USE_ICONV && defined HAVE_ICONV_H
if (to_server_enc)
convert(&new, to_server_enc);
@ -765,7 +766,7 @@ dav_get_file(const char *path, const char *cache_path, off_t *size,
if (mime && value) {
if (*mime)
free(*mime);
*mime = ne_strdup(value);
*mime = xstrdup(value);
}
}

@ -815,7 +816,7 @@ dav_head(const char *path, char **etag, time_t *mtime, off_t *length,
if (!ret && mime && value) {
if (*mime)
free(*mime);
*mime = ne_strdup(value);
*mime = xstrdup(value);
}

ne_request_destroy(req);
@ -861,7 +862,7 @@ dav_lock(const char *path, time_t *expire, int *exists)
lock = ne_lock_create();
ne_fill_server_uri(session, &lock->uri);
lock->uri.path = spath;
lock->owner = ne_strdup(owner);
lock->owner = xstrdup(owner);
lock->timeout = lock_timeout;

#if NE_VERSION_MINOR > 25
@ -1104,7 +1105,7 @@ dav_put(const char *path, const char *cache_path, int *exists, time_t *expire,
if (value) {
if (*mime)
free(*mime);
*mime = ne_strdup(value);
*mime = xstrdup(value);
}
}
}
@ -1269,8 +1270,7 @@ convert(char **s, iconv_t conv)
size_t insize = strlen(*s);
char *in = *s;
size_t outsize = MB_LEN_MAX * (insize + 1);
char *buf = calloc(outsize, 1);
if (!buf) abort();
char *buf = xcalloc(outsize, 1);
char *out = buf;

iconv(conv, NULL, NULL, &out, &outsize);
@ -1725,7 +1725,7 @@ prop_result(void *userdata, const char *href, const ne_prop_result_set *set)
return;
}

char *tmp_path = (char *) ne_malloc(strlen(uri.path) + 1);
char *tmp_path = (char *) xmalloc(strlen(uri.path) + 1);
const char *from = uri.path;

#else /* NE_VERSION_MINOR >= 26 */
@ -1737,7 +1737,7 @@ prop_result(void *userdata, const ne_uri *uri, const ne_prop_result_set *set)
if (!ctx || !uri || !uri->path || !set)
return;

char *tmp_path = (char *) ne_malloc(strlen(uri->path) + 1);
char *tmp_path = (char *) xmalloc(strlen(uri->path) + 1);
const char *from = uri->path;

#endif /* NE_VERSION_MINOR >= 26 */
@ -1749,7 +1749,7 @@ prop_result(void *userdata, const ne_uri *uri, const ne_prop_result_set *set)
*to++ = *from++;
}
*to = 0;
dav_props *result = ne_calloc(sizeof(dav_props));
dav_props *result = xcalloc(1, sizeof(dav_props));
result->path = ne_path_unescape(tmp_path);
free (tmp_path);

@ -1788,7 +1788,7 @@ prop_result(void *userdata, const ne_uri *uri, const ne_prop_result_set *set)
}

if (strcmp(result->path, ctx->path) == 0) {
result->name = ne_strdup("");
result->name = xstrdup("");
} else {
if (strlen(result->path) < (strlen(ctx->path) + result->is_dir + 1)) {
dav_delete_props(result);
@ -1945,7 +1945,7 @@ ssl_verify(void *userdata, int failures, const ne_ssl_certificate *cert)
{
char *issuer = ne_ssl_readable_dname(ne_ssl_cert_issuer(cert));
char *subject = ne_ssl_readable_dname(ne_ssl_cert_subject(cert));
char *digest = ne_calloc(NE_SSL_DIGESTLEN);
char *digest = xcalloc(1, NE_SSL_DIGESTLEN);
if (!issuer || !subject || ne_ssl_cert_digest(cert, digest) != 0) {
if (have_terminal) {
error(0, 0, _("error processing server certificate"));