Add Gnulib module xalloc
This commit is contained in:
parent
828ded4558
commit
6559f12463
@ -10,6 +10,8 @@ ChangeLog for davfs2
|
|||||||
Use getgroups.
|
Use getgroups.
|
||||||
* mount_davfs.c, check_dirs, read_secrets:
|
* mount_davfs.c, check_dirs, read_secrets:
|
||||||
Check secrets file in check_dirs.
|
Check secrets file in check_dirs.
|
||||||
|
* all:
|
||||||
|
Add Gnulib module xalloc.
|
||||||
|
|
||||||
2012-01-25 Werner Baumann (werner.baumann@onlinehome.de)
|
2012-01-25 Werner Baumann (werner.baumann@onlinehome.de)
|
||||||
* mount_davfs.c, mount_davfs.h:
|
* mount_davfs.c, mount_davfs.h:
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
|
|
||||||
# Specification in the form of a command-line invocation:
|
# 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:
|
# Specification in the form of a few gnulib-tool.m4 macro invocations:
|
||||||
gl_LOCAL_DIR([])
|
gl_LOCAL_DIR([])
|
||||||
@ -23,6 +23,7 @@ gl_MODULES([
|
|||||||
canonicalize
|
canonicalize
|
||||||
iconv_open
|
iconv_open
|
||||||
rpmatch
|
rpmatch
|
||||||
|
xalloc
|
||||||
])
|
])
|
||||||
gl_AVOID([])
|
gl_AVOID([])
|
||||||
gl_SOURCE_BASE([gl])
|
gl_SOURCE_BASE([gl])
|
||||||
|
47
src/cache.c
47
src/cache.c
@ -59,6 +59,8 @@
|
|||||||
#endif
|
#endif
|
||||||
#include <sys/xattr.h>
|
#include <sys/xattr.h>
|
||||||
|
|
||||||
|
#include "xalloc.h"
|
||||||
|
|
||||||
#include <ne_alloc.h>
|
#include <ne_alloc.h>
|
||||||
#include <ne_string.h>
|
#include <ne_string.h>
|
||||||
#include <ne_xml.h>
|
#include <ne_xml.h>
|
||||||
@ -600,7 +602,7 @@ dav_init_cache(const dav_args *args, const char *mpoint)
|
|||||||
dir_umask = args->dir_umask;
|
dir_umask = args->dir_umask;
|
||||||
|
|
||||||
table_size = args->table_size;
|
table_size = args->table_size;
|
||||||
table = ne_calloc(sizeof(*table) * table_size);
|
table = xcalloc(table_size, sizeof(*table));
|
||||||
|
|
||||||
dir_refresh = args->dir_refresh;
|
dir_refresh = args->dir_refresh;
|
||||||
file_refresh = args->file_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;
|
max_upload_attempts = args->max_upload_attempts;
|
||||||
lock_refresh = args->lock_refresh;
|
lock_refresh = args->lock_refresh;
|
||||||
|
|
||||||
fs_stat = (dav_stat *) malloc(sizeof(dav_stat));
|
fs_stat = (dav_stat *) xmalloc(sizeof(dav_stat));
|
||||||
if (!fs_stat) abort();
|
|
||||||
|
|
||||||
fs_stat->blocks = 0x65B9AA;
|
fs_stat->blocks = 0x65B9AA;
|
||||||
fs_stat->bfree = 0x32DCD5;
|
fs_stat->bfree = 0x32DCD5;
|
||||||
@ -640,13 +641,13 @@ dav_init_cache(const dav_args *args, const char *mpoint)
|
|||||||
if (debug)
|
if (debug)
|
||||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "Reading stored cache data");
|
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "Reading stored cache data");
|
||||||
parse_index();
|
parse_index();
|
||||||
root->name = ne_strdup("");
|
root->name = xstrdup("");
|
||||||
root->path = dav_conv_to_server_enc(args->path);
|
root->path = dav_conv_to_server_enc(args->path);
|
||||||
root->mode = default_dir_mode;
|
root->mode = default_dir_mode;
|
||||||
|
|
||||||
if (!backup)
|
if (!backup)
|
||||||
backup = new_node(root, S_IFDIR | S_IRWXU);
|
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;
|
backup->mode = S_IFDIR | S_IRWXU;
|
||||||
|
|
||||||
clean_cache();
|
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 = new_node(parent, mode | S_IFREG);
|
||||||
(*nodep)->path = path;
|
(*nodep)->path = path;
|
||||||
(*nodep)->name = ne_strdup(name);
|
(*nodep)->name = xstrdup(name);
|
||||||
(*nodep)->uid = uid;
|
(*nodep)->uid = uid;
|
||||||
(*nodep)->gid = pw->pw_gid;
|
(*nodep)->gid = pw->pw_gid;
|
||||||
int ret = create_cache_file(*nodep);
|
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) {
|
if (!ret) {
|
||||||
*nodep = new_node(parent, mode | S_IFDIR);
|
*nodep = new_node(parent, mode | S_IFDIR);
|
||||||
(*nodep)->path = path;
|
(*nodep)->path = path;
|
||||||
(*nodep)->name = ne_strdup(name);
|
(*nodep)->name = xstrdup(name);
|
||||||
(*nodep)->uid = uid;
|
(*nodep)->uid = uid;
|
||||||
(*nodep)->gid = pw->pw_gid;
|
(*nodep)->gid = pw->pw_gid;
|
||||||
(*nodep)->smtime = (*nodep)->mtime;
|
(*nodep)->smtime = (*nodep)->mtime;
|
||||||
@ -1680,9 +1681,7 @@ add_to_changed(dav_node *node)
|
|||||||
return;
|
return;
|
||||||
chp = &(*chp)->next;
|
chp = &(*chp)->next;
|
||||||
}
|
}
|
||||||
*chp = (dav_node_list_item *) malloc(sizeof(dav_node_list_item));
|
*chp = (dav_node_list_item *) xmalloc(sizeof(dav_node_list_item));
|
||||||
if (!*chp)
|
|
||||||
abort();
|
|
||||||
(*chp)->node = node;
|
(*chp)->node = node;
|
||||||
(*chp)->next = NULL;
|
(*chp)->next = NULL;
|
||||||
(*chp)->attempts = 0;
|
(*chp)->attempts = 0;
|
||||||
@ -1702,7 +1701,7 @@ backup_node(dav_node *orig)
|
|||||||
if (!orig->cache_path)
|
if (!orig->cache_path)
|
||||||
return;
|
return;
|
||||||
dav_node *node = new_node(backup, orig->mode);
|
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;
|
node->cache_path = orig->cache_path;
|
||||||
orig->cache_path = NULL;
|
orig->cache_path = NULL;
|
||||||
node->mime_type = orig->mime_type;
|
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);
|
dst_path = ne_concat(dst_parent->path, dst_conv, "/", NULL);
|
||||||
free(dst_conv);
|
free(dst_conv);
|
||||||
} else {
|
} else {
|
||||||
dst_path = ne_strdup(dst->path);
|
dst_path = xstrdup(dst->path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dav_move(src->path, dst_path) != 0) {
|
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);
|
remove_node(dst);
|
||||||
|
|
||||||
free(src->name);
|
free(src->name);
|
||||||
src->name = ne_strdup(dst_name);
|
src->name = xstrdup(dst_name);
|
||||||
update_path(src, src->path, dst_path);
|
update_path(src, src->path, dst_path);
|
||||||
free(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);
|
dst_path = ne_concat(dst_parent->path, dst_conv, NULL);
|
||||||
free(dst_conv);
|
free(dst_conv);
|
||||||
} else {
|
} else {
|
||||||
dst_path = ne_strdup(dst->path);
|
dst_path = xstrdup(dst->path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dst) {
|
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);
|
dav_set_execute(dst_path, 1);
|
||||||
|
|
||||||
free(src->name);
|
free(src->name);
|
||||||
src->name = ne_strdup(dst_name);
|
src->name = xstrdup(dst_name);
|
||||||
free(src->path);
|
free(src->path);
|
||||||
src->path = dst_path;
|
src->path = dst_path;
|
||||||
if (src->etag) {
|
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);
|
dst_path = ne_concat(dst_parent->path, dst_conv, NULL);
|
||||||
free(dst_conv);
|
free(dst_conv);
|
||||||
} else {
|
} else {
|
||||||
dst_path = ne_strdup(dst->path);
|
dst_path = xstrdup(dst->path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dav_move(src->path, dst_path) != 0) {
|
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);
|
free(src->name);
|
||||||
src->name = ne_strdup(dst_name);
|
src->name = xstrdup(dst_name);
|
||||||
free(src->path);
|
free(src->path);
|
||||||
src->path = dst_path;
|
src->path = dst_path;
|
||||||
src->utime = time(NULL);
|
src->utime = time(NULL);
|
||||||
@ -2022,7 +2021,7 @@ move_reg(dav_node *src, dav_node *dst, dav_node *dst_parent,
|
|||||||
static dav_node *
|
static dav_node *
|
||||||
new_node(dav_node *parent, mode_t mode)
|
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->parent = parent;
|
||||||
node->childs = NULL;
|
node->childs = NULL;
|
||||||
@ -2297,7 +2296,7 @@ update_node(dav_node *node, dav_props *props)
|
|||||||
|
|
||||||
if (strcmp(node->name, props->name) != 0) {
|
if (strcmp(node->name, props->name) != 0) {
|
||||||
free(node->name);
|
free(node->name);
|
||||||
node->name = ne_strdup(props->name);
|
node->name = xstrdup(props->name);
|
||||||
ret = 1;
|
ret = 1;
|
||||||
*flush = 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);
|
*fd = open(node->cache_path, flags, node->mode);
|
||||||
if (*fd <= 0)
|
if (*fd <= 0)
|
||||||
return EIO;
|
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->fd = *fd;
|
||||||
fh->flags = O_ACCMODE & flags;
|
fh->flags = O_ACCMODE & flags;
|
||||||
fh->pid = pid;
|
fh->pid = pid;
|
||||||
@ -2854,7 +2853,7 @@ clean_cache(void)
|
|||||||
dav_node *found = new_node(backup, default_file_mode);
|
dav_node *found = new_node(backup, default_file_mode);
|
||||||
found->mode &= ~(S_IRWXG | S_IRWXO);
|
found->mode &= ~(S_IRWXG | S_IRWXO);
|
||||||
found->cache_path = path;
|
found->cache_path = path;
|
||||||
found->name = ne_strdup(de->d_name);
|
found->name = xstrdup(de->d_name);
|
||||||
attr_from_cache_file(found);
|
attr_from_cache_file(found);
|
||||||
backup->mtime = time(NULL);
|
backup->mtime = time(NULL);
|
||||||
backup->ctime = backup->mtime;
|
backup->ctime = backup->mtime;
|
||||||
@ -2884,7 +2883,7 @@ parse_index(void)
|
|||||||
return;
|
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);
|
size_t len = fread(buf, 1, DAV_XML_BUF_SIZE, idx);
|
||||||
if (len <= 0) {
|
if (len <= 0) {
|
||||||
free(buf);
|
free(buf);
|
||||||
@ -3780,8 +3779,8 @@ test_alignment()
|
|||||||
|
|
||||||
size_t j = 0;
|
size_t j = 0;
|
||||||
while (align > 0 && j < trials) {
|
while (align > 0 && j < trials) {
|
||||||
s[j] = (char *) ne_malloc((rand() / (RAND_MAX / 1024)) % (4 *align));
|
s[j] = (char *) xmalloc((rand() / (RAND_MAX / 1024)) % (4 *align));
|
||||||
n[j] = (dav_node *) ne_malloc(sizeof(dav_node));
|
n[j] = (dav_node *) xmalloc(sizeof(dav_node));
|
||||||
while (align > 0 && ((size_t) n[j] % align) > 0)
|
while (align > 0 && ((size_t) n[j] % align) > 0)
|
||||||
align /= 2;
|
align /= 2;
|
||||||
++j;
|
++j;
|
||||||
|
@ -54,6 +54,8 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "xalloc.h"
|
||||||
|
|
||||||
#include "defaults.h"
|
#include "defaults.h"
|
||||||
#include "mount_davfs.h"
|
#include "mount_davfs.h"
|
||||||
#include "cache.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)
|
const char *mpoint, const dav_args *args)
|
||||||
{
|
{
|
||||||
if (!*kernel_fs)
|
if (!*kernel_fs)
|
||||||
*kernel_fs = strdup("fuse");
|
*kernel_fs = xstrdup("fuse");
|
||||||
if (!*kernel_fs) abort();
|
|
||||||
|
|
||||||
int mounted = 0;
|
int mounted = 0;
|
||||||
if (strcmp(*kernel_fs, "coda") == 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)
|
args->mopts, args->fsuid, args->fsgid, args->dir_mode)
|
||||||
== 0) {
|
== 0) {
|
||||||
free(*kernel_fs);
|
free(*kernel_fs);
|
||||||
*kernel_fs = strdup("fuse");
|
*kernel_fs = xstrdup("fuse");
|
||||||
if (!*kernel_fs) abort();
|
|
||||||
mounted = 1;
|
mounted = 1;
|
||||||
error(0, 0, _("fuse device opened successfully"));
|
error(0, 0, _("fuse device opened successfully"));
|
||||||
} else {
|
} 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"));
|
error(0, 0, _("trying coda kernel file system"));
|
||||||
if (init_coda(dev, msg_loop, mdata) == 0) {
|
if (init_coda(dev, msg_loop, mdata) == 0) {
|
||||||
free(*kernel_fs);
|
free(*kernel_fs);
|
||||||
*kernel_fs = strdup("coda");
|
*kernel_fs = xstrdup("coda");
|
||||||
if (*kernel_fs == NULL)
|
|
||||||
abort();
|
|
||||||
error(0, 0, _("coda device opened successfully"));
|
error(0, 0, _("coda device opened successfully"));
|
||||||
} else {
|
} else {
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
@ -203,8 +201,7 @@ init_coda(int *dev, dav_run_msgloop_fn *msg_loop, void **mdata)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct coda_mount_data *md = malloc(sizeof(struct coda_mount_data));
|
struct coda_mount_data *md = xmalloc(sizeof(struct coda_mount_data));
|
||||||
if (!md) abort();
|
|
||||||
md->version = CODA_MOUNT_VERSION;
|
md->version = CODA_MOUNT_VERSION;
|
||||||
md->fd = *dev;
|
md->fd = *dev;
|
||||||
*mdata = md;
|
*mdata = md;
|
||||||
|
@ -69,12 +69,14 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "canonicalize.h"
|
||||||
|
#include "xalloc.h"
|
||||||
|
|
||||||
#include <ne_string.h>
|
#include <ne_string.h>
|
||||||
#include <ne_uri.h>
|
#include <ne_uri.h>
|
||||||
#include <ne_utils.h>
|
#include <ne_utils.h>
|
||||||
|
|
||||||
#include "defaults.h"
|
#include "defaults.h"
|
||||||
#include "canonicalize.h"
|
|
||||||
#include "mount_davfs.h"
|
#include "mount_davfs.h"
|
||||||
#include "kernel_interface.h"
|
#include "kernel_interface.h"
|
||||||
#include "cache.h"
|
#include "cache.h"
|
||||||
@ -268,7 +270,7 @@ main(int argc, char *argv[])
|
|||||||
dav_run_msgloop_fn run_msgloop = NULL;
|
dav_run_msgloop_fn run_msgloop = NULL;
|
||||||
void *mdata = NULL;
|
void *mdata = NULL;
|
||||||
if (args->kernel_fs)
|
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;
|
size_t buf_size = args->buf_size * 1024;
|
||||||
gain_privileges(args);
|
gain_privileges(args);
|
||||||
int mounted = dav_init_kernel_interface(&dev, &run_msgloop, &mdata,
|
int mounted = dav_init_kernel_interface(&dev, &run_msgloop, &mdata,
|
||||||
@ -650,7 +652,7 @@ check_double_mounts(dav_args *args)
|
|||||||
char *m = mpoint;
|
char *m = mpoint;
|
||||||
while (*m == '/')
|
while (*m == '/')
|
||||||
m++;
|
m++;
|
||||||
char *mp = ne_strdup(m);
|
char *mp = xstrdup(m);
|
||||||
m = strchr(mp, '/');
|
m = strchr(mp, '/');
|
||||||
while (m) {
|
while (m) {
|
||||||
*m = '-';
|
*m = '-';
|
||||||
@ -882,8 +884,7 @@ parse_commandline(dav_args *args, int argc, char *argv[])
|
|||||||
int i;
|
int i;
|
||||||
for (i = 0; i < argc; i++)
|
for (i = 0; i < argc; i++)
|
||||||
len += strlen(argv[i]);
|
len += strlen(argv[i]);
|
||||||
args->cmdline = malloc(len);
|
args->cmdline = xmalloc(len);
|
||||||
if (!args->cmdline) abort();
|
|
||||||
char *p = args->cmdline;
|
char *p = args->cmdline;
|
||||||
for (i = 0; i < argc - 1; i++) {
|
for (i = 0; i < argc - 1; i++) {
|
||||||
strcpy(p, argv[i]);
|
strcpy(p, argv[i]);
|
||||||
@ -939,7 +940,7 @@ parse_commandline(dav_args *args, int argc, char *argv[])
|
|||||||
if (*argv[i] == '\"' || *argv[i] == '\'') {
|
if (*argv[i] == '\"' || *argv[i] == '\'') {
|
||||||
url = ne_strndup(argv[i] + 1, strlen(argv[i]) -2);
|
url = ne_strndup(argv[i] + 1, strlen(argv[i]) -2);
|
||||||
} else {
|
} else {
|
||||||
url = ne_strdup(argv[i]);
|
url = xstrdup(argv[i]);
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
mpoint = canonicalize_file_name(argv[i]);
|
mpoint = canonicalize_file_name(argv[i]);
|
||||||
@ -1002,7 +1003,7 @@ parse_config(dav_args *args)
|
|||||||
read_config(args, args->conf, 0);
|
read_config(args, args->conf, 0);
|
||||||
|
|
||||||
if (!args->dav_user)
|
if (!args->dav_user)
|
||||||
args->dav_user = ne_strdup(DAV_USER);
|
args->dav_user = xstrdup(DAV_USER);
|
||||||
struct passwd *pw = getpwnam(args->dav_user);
|
struct passwd *pw = getpwnam(args->dav_user);
|
||||||
if (!pw)
|
if (!pw)
|
||||||
error(EXIT_FAILURE, errno, _("user %s does not exist"),
|
error(EXIT_FAILURE, errno, _("user %s does not exist"),
|
||||||
@ -1010,7 +1011,7 @@ parse_config(dav_args *args)
|
|||||||
args->dav_uid = pw->pw_uid;
|
args->dav_uid = pw->pw_uid;
|
||||||
|
|
||||||
if (!args->dav_group)
|
if (!args->dav_group)
|
||||||
args->dav_group = ne_strdup(DAV_GROUP);
|
args->dav_group = xstrdup(DAV_GROUP);
|
||||||
struct group *grp = getgrnam(args->dav_group);
|
struct group *grp = getgrnam(args->dav_group);
|
||||||
if (!grp)
|
if (!grp)
|
||||||
error(EXIT_FAILURE, errno, _("group %s does not exist"),
|
error(EXIT_FAILURE, errno, _("group %s does not exist"),
|
||||||
@ -1089,9 +1090,9 @@ parse_config(dav_args *args)
|
|||||||
args->useproxy = 0;
|
args->useproxy = 0;
|
||||||
|
|
||||||
if (!args->sys_cache)
|
if (!args->sys_cache)
|
||||||
args->sys_cache = ne_strdup(DAV_SYS_CACHE);
|
args->sys_cache = xstrdup(DAV_SYS_CACHE);
|
||||||
if (args->privileged) {
|
if (args->privileged) {
|
||||||
args->cache_dir = ne_strdup(args->sys_cache);
|
args->cache_dir = xstrdup(args->sys_cache);
|
||||||
} else {
|
} else {
|
||||||
if (args->cache_dir) {
|
if (args->cache_dir) {
|
||||||
expand_home(&args->cache_dir, args);
|
expand_home(&args->cache_dir, args);
|
||||||
@ -1102,7 +1103,7 @@ parse_config(dav_args *args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!args->backup_dir)
|
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)
|
if (args->debug & DAV_DBG_CONFIG)
|
||||||
log_dbg_config(args);
|
log_dbg_config(args);
|
||||||
@ -1129,15 +1130,13 @@ parse_persona(dav_args *args)
|
|||||||
struct passwd *pw = getpwuid(args->uid);
|
struct passwd *pw = getpwuid(args->uid);
|
||||||
if (!pw || !pw->pw_name || !pw->pw_dir)
|
if (!pw || !pw->pw_name || !pw->pw_dir)
|
||||||
error(EXIT_FAILURE, errno, _("can't read user data base"));
|
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);
|
args->home = canonicalize_file_name(pw->pw_dir);
|
||||||
if (!args->uid_name || !args->home) abort();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
args->ngroups = getgroups(0, NULL);
|
args->ngroups = getgroups(0, NULL);
|
||||||
if (args->ngroups) {
|
if (args->ngroups) {
|
||||||
args->groups = (gid_t *) malloc(args->ngroups * sizeof(gid_t));
|
args->groups = (gid_t *) xmalloc(args->ngroups * sizeof(gid_t));
|
||||||
if (!args->groups) abort();
|
|
||||||
if (getgroups(args->ngroups, args->groups) < 0)
|
if (getgroups(args->ngroups, args->groups) < 0)
|
||||||
error(EXIT_FAILURE, 0, _("can't read group data base"));
|
error(EXIT_FAILURE, 0, _("can't read group data base"));
|
||||||
}
|
}
|
||||||
@ -1625,12 +1624,12 @@ get_options(dav_args *args, char *option)
|
|||||||
case CONF:
|
case CONF:
|
||||||
if (args->conf)
|
if (args->conf)
|
||||||
free(args->conf);
|
free(args->conf);
|
||||||
args->conf = ne_strdup(argument);
|
args->conf = xstrdup(argument);
|
||||||
break;
|
break;
|
||||||
case USERNAME:
|
case USERNAME:
|
||||||
if (args->cl_username)
|
if (args->cl_username)
|
||||||
free(args->cl_username);
|
free(args->cl_username);
|
||||||
args->cl_username = ne_strdup(argument);
|
args->cl_username = xstrdup(argument);
|
||||||
break;
|
break;
|
||||||
case UID:
|
case UID:
|
||||||
pwd = getpwnam(argument);
|
pwd = getpwnam(argument);
|
||||||
@ -1734,8 +1733,7 @@ get_options(dav_args *args, char *option)
|
|||||||
static dav_args *
|
static dav_args *
|
||||||
new_args(void)
|
new_args(void)
|
||||||
{
|
{
|
||||||
dav_args *args = (dav_args *) calloc(1, sizeof(dav_args));
|
dav_args *args = (dav_args *) xcalloc(1, sizeof(dav_args));
|
||||||
if (!args) abort();
|
|
||||||
|
|
||||||
args->netdev = DAV_NETDEV;
|
args->netdev = DAV_NETDEV;
|
||||||
args->mopts = DAV_USER_MOPTS;
|
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 (system && strcmp(parmv[0], "dav_user") == 0) {
|
||||||
if (args->dav_user)
|
if (args->dav_user)
|
||||||
free(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) {
|
} else if (system && strcmp(parmv[0], "dav_group") == 0) {
|
||||||
if (args->dav_group)
|
if (args->dav_group)
|
||||||
free(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) {
|
} else if (strcmp(parmv[0], "kernel_fs") == 0) {
|
||||||
if (args->kernel_fs)
|
if (args->kernel_fs)
|
||||||
free(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) {
|
} else if (strcmp(parmv[0], "buf_size") == 0) {
|
||||||
args->buf_size = arg_to_int(parmv[1], 10, parmv[0]);
|
args->buf_size = arg_to_int(parmv[1], 10, parmv[0]);
|
||||||
} else if (strcmp(parmv[0], "servercert") == 0) {
|
} else if (strcmp(parmv[0], "servercert") == 0) {
|
||||||
if (args->servercert)
|
if (args->servercert)
|
||||||
free(args->servercert);
|
free(args->servercert);
|
||||||
args->servercert = ne_strdup(parmv[1]);
|
args->servercert = xstrdup(parmv[1]);
|
||||||
} else if (!system && strcmp(parmv[0], "secrets") == 0) {
|
} else if (!system && strcmp(parmv[0], "secrets") == 0) {
|
||||||
if (args->secrets)
|
if (args->secrets)
|
||||||
free(args->secrets);
|
free(args->secrets);
|
||||||
args->secrets = ne_strdup(parmv[1]);
|
args->secrets = xstrdup(parmv[1]);
|
||||||
} else if (strcmp(parmv[0], "clientcert") == 0) {
|
} else if (strcmp(parmv[0], "clientcert") == 0) {
|
||||||
if (args->clicert)
|
if (args->clicert)
|
||||||
free(args->clicert);
|
free(args->clicert);
|
||||||
args->clicert = ne_strdup(parmv[1]);
|
args->clicert = xstrdup(parmv[1]);
|
||||||
} else if (system && strcmp(parmv[0], "proxy") == 0) {
|
} else if (system && strcmp(parmv[0], "proxy") == 0) {
|
||||||
if (split_uri(NULL, &args->p_host, &args->p_port, NULL,
|
if (split_uri(NULL, &args->p_host, &args->p_port, NULL,
|
||||||
parmv[1]) != 0)
|
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) {
|
} else if (strcmp(parmv[0], "lock_owner") == 0) {
|
||||||
if (args->lock_owner)
|
if (args->lock_owner)
|
||||||
free(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) {
|
} else if (strcmp(parmv[0], "lock_timeout") == 0) {
|
||||||
args->lock_timeout = arg_to_int(parmv[1], 10, parmv[0]);
|
args->lock_timeout = arg_to_int(parmv[1], 10, parmv[0]);
|
||||||
} else if (strcmp(parmv[0], "lock_refresh") == 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) {
|
} else if (strcmp(parmv[0], "server_charset") == 0) {
|
||||||
if (args->s_charset)
|
if (args->s_charset)
|
||||||
free(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) {
|
} else if (system && strcmp(parmv[0], "cache_dir") == 0) {
|
||||||
if (args->sys_cache)
|
if (args->sys_cache)
|
||||||
free(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) {
|
} else if (!system && strcmp(parmv[0], "cache_dir") == 0) {
|
||||||
if (args->cache_dir != NULL)
|
if (args->cache_dir != NULL)
|
||||||
free(args->cache_dir);
|
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) {
|
} else if (strcmp(parmv[0], "backup_dir") == 0) {
|
||||||
if (args->backup_dir)
|
if (args->backup_dir)
|
||||||
free(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) {
|
} else if (strcmp(parmv[0], "cache_size") == 0) {
|
||||||
args->cache_size = arg_to_int(parmv[1], 10, parmv[0]);
|
args->cache_size = arg_to_int(parmv[1], 10, parmv[0]);
|
||||||
} else if (strcmp(parmv[0], "table_size") == 0) {
|
} else if (strcmp(parmv[0], "table_size") == 0) {
|
||||||
@ -2254,7 +2252,7 @@ read_no_proxy_list(dav_args *args)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *noproxy_list = ne_strdup(env);
|
char *noproxy_list = xstrdup(env);
|
||||||
char *np = strtok(noproxy_list, ", ");
|
char *np = strtok(noproxy_list, ", ");
|
||||||
while (np && args->p_host) {
|
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)
|
if (asprintf(&host, "%s:%d", args->host, args->port) < 0)
|
||||||
abort();
|
abort();
|
||||||
} else {
|
} else {
|
||||||
host = strdup(args->host);
|
host = xstrdup(args->host);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*np == '.') {
|
if (*np == '.') {
|
||||||
@ -2352,9 +2350,9 @@ read_secrets(dav_args *args, const char *filename)
|
|||||||
memset(args->password, '\0', strlen(args->password));
|
memset(args->password, '\0', strlen(args->password));
|
||||||
free(args->password);
|
free(args->password);
|
||||||
}
|
}
|
||||||
args->username = ne_strdup(parmv[1]);
|
args->username = xstrdup(parmv[1]);
|
||||||
if (count == 3)
|
if (count == 3)
|
||||||
args->password = ne_strdup(parmv[2]);
|
args->password = xstrdup(parmv[2]);
|
||||||
|
|
||||||
} else if (strcmp(parmv[0], "proxy") == 0
|
} else if (strcmp(parmv[0], "proxy") == 0
|
||||||
|| (host && args->p_host
|
|| (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));
|
memset(args->p_passwd, '\0', strlen(args->p_passwd));
|
||||||
free(args->p_passwd);
|
free(args->p_passwd);
|
||||||
}
|
}
|
||||||
args->p_user = ne_strdup(parmv[1]);
|
args->p_user = xstrdup(parmv[1]);
|
||||||
if (count == 3)
|
if (count == 3)
|
||||||
args->p_passwd = ne_strdup(parmv[2]);
|
args->p_passwd = xstrdup(parmv[2]);
|
||||||
|
|
||||||
} else if (args->clicert
|
} else if (args->clicert
|
||||||
&& (strcmp(parmv[0], args->clicert) == 0
|
&& (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));
|
memset(args->clicert_pw, '\0', strlen(args->clicert_pw));
|
||||||
free(args->clicert_pw);
|
free(args->clicert_pw);
|
||||||
}
|
}
|
||||||
args->clicert_pw = ne_strdup(parmv[1]);
|
args->clicert_pw = xstrdup(parmv[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scheme) free(scheme);
|
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) {
|
||||||
if (*scheme) free(*scheme);
|
if (*scheme) free(*scheme);
|
||||||
if (sch) {
|
if (sch) {
|
||||||
*scheme = strdup(sch);
|
*scheme = xstrdup(sch);
|
||||||
} else {
|
} else {
|
||||||
*scheme = strdup("http");
|
*scheme = xstrdup("http");
|
||||||
}
|
}
|
||||||
if (!*scheme) abort();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (port && po)
|
if (port && po)
|
||||||
@ -2479,8 +2476,7 @@ split_uri(char **scheme, char **host, int *port,char **path, const char *uri)
|
|||||||
|
|
||||||
if (host) {
|
if (host) {
|
||||||
if (*host) free(*host);
|
if (*host) free(*host);
|
||||||
*host = malloc(end - ho + 1);
|
*host = xmalloc(end - ho + 1);
|
||||||
if (!*host) abort();
|
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < (end - ho); i++) {
|
for (i = 0; i < (end - ho); i++) {
|
||||||
if (*ho == '[') {
|
if (*ho == '[') {
|
||||||
@ -2497,13 +2493,12 @@ split_uri(char **scheme, char **host, int *port,char **path, const char *uri)
|
|||||||
if (path) {
|
if (path) {
|
||||||
if (*path) free(*path);
|
if (*path) free(*path);
|
||||||
if (!*pa) {
|
if (!*pa) {
|
||||||
*path = strdup("/");
|
*path = xstrdup("/");
|
||||||
} else if (*(pa + strlen(pa) - 1) == '/') {
|
} else if (*(pa + strlen(pa) - 1) == '/') {
|
||||||
*path = strdup(pa);
|
*path = xstrdup(pa);
|
||||||
} else {
|
} else {
|
||||||
if (asprintf(path, "%s/", pa) < 1) abort();
|
if (asprintf(path, "%s/", pa) < 1) abort();
|
||||||
}
|
}
|
||||||
if (!*path) abort();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -40,6 +40,8 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "xalloc.h"
|
||||||
|
|
||||||
#include <ne_string.h>
|
#include <ne_string.h>
|
||||||
|
|
||||||
#include "defaults.h"
|
#include "defaults.h"
|
||||||
@ -132,7 +134,7 @@ main(int argc, char *argv[])
|
|||||||
char *m = mpoint;
|
char *m = mpoint;
|
||||||
while (*m == '/')
|
while (*m == '/')
|
||||||
m++;
|
m++;
|
||||||
char *mp = ne_strdup(m);
|
char *mp = xstrdup(m);
|
||||||
m = strchr(mp, '/');
|
m = strchr(mp, '/');
|
||||||
while (m) {
|
while (m) {
|
||||||
*m = '-';
|
*m = '-';
|
||||||
|
54
src/webdav.c
54
src/webdav.c
@ -56,6 +56,8 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "xalloc.h"
|
||||||
|
|
||||||
#include <ne_alloc.h>
|
#include <ne_alloc.h>
|
||||||
#include <ne_auth.h>
|
#include <ne_auth.h>
|
||||||
#include <ne_basic.h>
|
#include <ne_basic.h>
|
||||||
@ -354,9 +356,8 @@ dav_init_webdav(const dav_args *args)
|
|||||||
error(EXIT_FAILURE, errno, _("socket library initialization failed"));
|
error(EXIT_FAILURE, errno, _("socket library initialization failed"));
|
||||||
|
|
||||||
if (args->neon_debug & ~NE_DBG_HTTPPLAIN) {
|
if (args->neon_debug & ~NE_DBG_HTTPPLAIN) {
|
||||||
char *buf = malloc(log_bufsize);
|
char *buf = xmalloc(log_bufsize);
|
||||||
cookie_io_functions_t *log_func = malloc(sizeof(cookie_io_functions_t));
|
cookie_io_functions_t *log_func = xmalloc(sizeof(cookie_io_functions_t));
|
||||||
if (!log_func) abort();
|
|
||||||
log_func->read = NULL;
|
log_func->read = NULL;
|
||||||
log_func->write = log_writer;
|
log_func->write = log_writer;
|
||||||
log_func->seek = NULL;
|
log_func->seek = NULL;
|
||||||
@ -381,9 +382,9 @@ dav_init_webdav(const dav_args *args)
|
|||||||
free(useragent);
|
free(useragent);
|
||||||
|
|
||||||
if (args->username)
|
if (args->username)
|
||||||
username = ne_strdup(args->username);
|
username = xstrdup(args->username);
|
||||||
if (args->password)
|
if (args->password)
|
||||||
password = ne_strdup(args->password);
|
password = xstrdup(args->password);
|
||||||
#if NE_VERSION_MINOR < 26
|
#if NE_VERSION_MINOR < 26
|
||||||
ne_set_server_auth(session, auth, "server");
|
ne_set_server_auth(session, auth, "server");
|
||||||
#else /* NE_VERSION_MINOR >= 26 */
|
#else /* NE_VERSION_MINOR >= 26 */
|
||||||
@ -393,9 +394,9 @@ dav_init_webdav(const dav_args *args)
|
|||||||
if (args->useproxy && args->p_host) {
|
if (args->useproxy && args->p_host) {
|
||||||
ne_session_proxy(session, args->p_host, args->p_port);
|
ne_session_proxy(session, args->p_host, args->p_port);
|
||||||
if (args->p_user)
|
if (args->p_user)
|
||||||
p_username = ne_strdup(args->p_user);
|
p_username = xstrdup(args->p_user);
|
||||||
if (args->p_passwd)
|
if (args->p_passwd)
|
||||||
p_password = ne_strdup(args->p_passwd);
|
p_password = xstrdup(args->p_passwd);
|
||||||
#if NE_VERSION_MINOR < 26
|
#if NE_VERSION_MINOR < 26
|
||||||
ne_set_proxy_auth(session, auth, "proxy");
|
ne_set_proxy_auth(session, auth, "proxy");
|
||||||
#else /* NE_VERSION_MINOR >= 26 */
|
#else /* NE_VERSION_MINOR >= 26 */
|
||||||
@ -435,7 +436,7 @@ dav_init_webdav(const dav_args *args)
|
|||||||
"certificate %s.\n"), args->clicert);
|
"certificate %s.\n"), args->clicert);
|
||||||
pw = dav_user_input_hidden(_("Password: "));
|
pw = dav_user_input_hidden(_("Password: "));
|
||||||
} else {
|
} else {
|
||||||
pw = ne_strdup(args->clicert_pw);
|
pw = xstrdup(args->clicert_pw);
|
||||||
}
|
}
|
||||||
int ret = 1;
|
int ret = 1;
|
||||||
if (pw) {
|
if (pw) {
|
||||||
@ -459,18 +460,18 @@ dav_init_webdav(const dav_args *args)
|
|||||||
locks = ne_lockstore_create();
|
locks = ne_lockstore_create();
|
||||||
if (!args->lock_owner) {
|
if (!args->lock_owner) {
|
||||||
if (!args->username) {
|
if (!args->username) {
|
||||||
owner = ne_strdup(PACKAGE_STRING);
|
owner = xstrdup(PACKAGE_STRING);
|
||||||
} else {
|
} else {
|
||||||
owner = ne_strdup(args->username);
|
owner = xstrdup(args->username);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
owner = ne_strdup(args->lock_owner);
|
owner = xstrdup(args->lock_owner);
|
||||||
}
|
}
|
||||||
lock_timeout = args->lock_timeout;
|
lock_timeout = args->lock_timeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args->header) {
|
if (args->header) {
|
||||||
custom_header = ne_strdup(args->header);
|
custom_header = xstrdup(args->header);
|
||||||
ne_hook_pre_send(session, add_header, custom_header);
|
ne_hook_pre_send(session, add_header, custom_header);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -550,7 +551,7 @@ dav_close_webdav(void)
|
|||||||
char *
|
char *
|
||||||
dav_conv_from_utf_8(const char *s)
|
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 defined DAV_USE_ICONV && defined HAVE_ICONV_H
|
||||||
if (from_utf_8)
|
if (from_utf_8)
|
||||||
convert(&new, from_utf_8);
|
convert(&new, from_utf_8);
|
||||||
@ -562,7 +563,7 @@ dav_conv_from_utf_8(const char *s)
|
|||||||
char *
|
char *
|
||||||
dav_conv_to_utf_8(const char *s)
|
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 defined DAV_USE_ICONV && defined HAVE_ICONV_H
|
||||||
if (to_utf_8)
|
if (to_utf_8)
|
||||||
convert(&new, to_utf_8);
|
convert(&new, to_utf_8);
|
||||||
@ -574,7 +575,7 @@ dav_conv_to_utf_8(const char *s)
|
|||||||
char *
|
char *
|
||||||
dav_conv_from_server_enc(const char *s)
|
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 defined DAV_USE_ICONV && defined HAVE_ICONV_H
|
||||||
if (from_server_enc)
|
if (from_server_enc)
|
||||||
convert(&new, from_server_enc);
|
convert(&new, from_server_enc);
|
||||||
@ -586,7 +587,7 @@ dav_conv_from_server_enc(const char *s)
|
|||||||
char *
|
char *
|
||||||
dav_conv_to_server_enc(const char *s)
|
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 defined DAV_USE_ICONV && defined HAVE_ICONV_H
|
||||||
if (to_server_enc)
|
if (to_server_enc)
|
||||||
convert(&new, 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 && value) {
|
||||||
if (*mime)
|
if (*mime)
|
||||||
free(*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 (!ret && mime && value) {
|
||||||
if (*mime)
|
if (*mime)
|
||||||
free(*mime);
|
free(*mime);
|
||||||
*mime = ne_strdup(value);
|
*mime = xstrdup(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
ne_request_destroy(req);
|
ne_request_destroy(req);
|
||||||
@ -861,7 +862,7 @@ dav_lock(const char *path, time_t *expire, int *exists)
|
|||||||
lock = ne_lock_create();
|
lock = ne_lock_create();
|
||||||
ne_fill_server_uri(session, &lock->uri);
|
ne_fill_server_uri(session, &lock->uri);
|
||||||
lock->uri.path = spath;
|
lock->uri.path = spath;
|
||||||
lock->owner = ne_strdup(owner);
|
lock->owner = xstrdup(owner);
|
||||||
lock->timeout = lock_timeout;
|
lock->timeout = lock_timeout;
|
||||||
|
|
||||||
#if NE_VERSION_MINOR > 25
|
#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 (value) {
|
||||||
if (*mime)
|
if (*mime)
|
||||||
free(*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);
|
size_t insize = strlen(*s);
|
||||||
char *in = *s;
|
char *in = *s;
|
||||||
size_t outsize = MB_LEN_MAX * (insize + 1);
|
size_t outsize = MB_LEN_MAX * (insize + 1);
|
||||||
char *buf = calloc(outsize, 1);
|
char *buf = xcalloc(outsize, 1);
|
||||||
if (!buf) abort();
|
|
||||||
char *out = buf;
|
char *out = buf;
|
||||||
|
|
||||||
iconv(conv, NULL, NULL, &out, &outsize);
|
iconv(conv, NULL, NULL, &out, &outsize);
|
||||||
@ -1725,7 +1725,7 @@ prop_result(void *userdata, const char *href, const ne_prop_result_set *set)
|
|||||||
return;
|
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;
|
const char *from = uri.path;
|
||||||
|
|
||||||
#else /* NE_VERSION_MINOR >= 26 */
|
#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)
|
if (!ctx || !uri || !uri->path || !set)
|
||||||
return;
|
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;
|
const char *from = uri->path;
|
||||||
|
|
||||||
#endif /* NE_VERSION_MINOR >= 26 */
|
#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++ = *from++;
|
||||||
}
|
}
|
||||||
*to = 0;
|
*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);
|
result->path = ne_path_unescape(tmp_path);
|
||||||
free (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) {
|
if (strcmp(result->path, ctx->path) == 0) {
|
||||||
result->name = ne_strdup("");
|
result->name = xstrdup("");
|
||||||
} else {
|
} else {
|
||||||
if (strlen(result->path) < (strlen(ctx->path) + result->is_dir + 1)) {
|
if (strlen(result->path) < (strlen(ctx->path) + result->is_dir + 1)) {
|
||||||
dav_delete_props(result);
|
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 *issuer = ne_ssl_readable_dname(ne_ssl_cert_issuer(cert));
|
||||||
char *subject = ne_ssl_readable_dname(ne_ssl_cert_subject(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 (!issuer || !subject || ne_ssl_cert_digest(cert, digest) != 0) {
|
||||||
if (have_terminal) {
|
if (have_terminal) {
|
||||||
error(0, 0, _("error processing server certificate"));
|
error(0, 0, _("error processing server certificate"));
|
||||||
|
Loading…
Reference in New Issue
Block a user