Remove gnulib

This commit is contained in:
wbaumann 2020-08-12 10:40:55 +00:00
parent 75e9a82289
commit 21aae32da7
11 changed files with 225 additions and 257 deletions

View File

@ -1,6 +1,9 @@
ChangeLog for davfs2
--------------------

2020-08-12 Werner Baumann (werner.baumann@onlinehome.de)
* Remove gnulib.

2020-06-07 Werner Baumann (werner.baumann@onlinehome.de)
* webdav.c, get_cookies:
New parser for cookies (bug #58459).

View File

@ -20,9 +20,8 @@
## Process this file with automake to produce Makefile.in

EXTRA_DIST = bootstrap BUGS FAQ README.translators \
config/COPYING.davfs2 config/INSTALL.davfs2 \
config/gnulib-cache.m4
SUBDIRS = gl glpo po etc man src
config/COPYING.davfs2 config/INSTALL.davfs2
SUBDIRS = po etc man src
ACLOCAL_AMFLAGS = -I config
doc_DATA = AUTHORS BUGS ChangeLog COPYING FAQ INSTALL NEWS README \
README.translators THANKS TODO

View File

@ -8,7 +8,6 @@

set -ex
autopoint --force
gnulib-tool --update
cd man; po4a po4a.conf; cd ..
aclocal -I config
autoheader

View File

@ -1,53 +0,0 @@
# Copyright (C) 2002-2014 Free Software Foundation, Inc.
#
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This file is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this file. If not, see <http://www.gnu.org/licenses/>.
#
# As a special exception to the GNU General Public License,
# this file may be distributed as part of a program that
# contains a configuration script generated by Autoconf, under
# the same distribution terms as the rest of that program.
#
# Generated by gnulib-tool.
#
# This file represents the specification of how gnulib-tool is used.
# It acts as a cache: It is written and read by gnulib-tool.
# In projects that use version control, this file is meant to be put under
# version control, like the configure.ac and various Makefile.am files.


# 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-conditional-dependencies --no-libtool --macro-prefix=gl --po-domain=davfs2 canonicalize iconv_open rpmatch stdalign xalloc xstrndup xvasprintf

# Specification in the form of a few gnulib-tool.m4 macro invocations:
gl_LOCAL_DIR([])
gl_MODULES([
canonicalize
iconv_open
rpmatch
stdalign
xalloc
xstrndup
xvasprintf
])
gl_AVOID([])
gl_SOURCE_BASE([gl])
gl_M4_BASE([config])
gl_PO_BASE([glpo])
gl_DOC_BASE([doc])
gl_TESTS_BASE([tests])
gl_LIB([libgnu])
gl_MAKEFILE_NAME([])
gl_MACRO_PREFIX([gl])
gl_PO_DOMAIN([davfs2])
gl_WITNESS_C_MACRO([])

View File

@ -95,8 +95,6 @@ AC_CONFIG_FILES([Makefile
man/Makefile
man/de/Makefile
man/es/Makefile
src/Makefile
gl/Makefile
glpo/Makefile.in])
src/Makefile])
AC_OUTPUT
DAV_MESSAGE

View File

@ -32,7 +32,6 @@ mount_davfs_SOURCES = cache.c \
kernel_interface.h mount_davfs.h webdav.h
umount_davfs_SOURCES = umount_davfs.c defaults.h

AM_CPPFLAGS = -I$(top_builddir)/gl -I$(top_srcdir)/gl
AM_CFLAGS = -Wall -Werror=format-security \
-fstack-protector --param=ssp-buffer-size=4
DEFS = -DPROGRAM_NAME=\"mount.davfs\" \
@ -50,8 +49,6 @@ DEFS = -DPROGRAM_NAME=\"mount.davfs\" \
-DDAV_GROUP=\"$(dav_group)\" \
-D_FORTIFY_SOURCE=2 @DEFS@
LIBS = $(NEON_LIBS) @LIBS@
mount_davfs_LDADD = $(LIBINTL) $(LIBICONV) $(LIBTHREAD) ../gl/libgnu.a
umount_davfs_LDADD = $(LIBINTL) ../gl/libgnu.a

install-exec-hook:
chmod u+s $(DESTDIR)$(sbindir)/mount.davfs; \

View File

@ -63,10 +63,7 @@
#endif
#include <sys/xattr.h>

#include "xalloc.h"
#include "xstrndup.h"
#include "xvasprintf.h"

#include <ne_alloc.h>
#include <ne_ssl.h>
#include <ne_xml.h>

@ -596,7 +593,7 @@ dav_init_cache(const dav_args *args, const char *mpoint)
grpid = args->grpid;

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

dir_refresh = args->dir_refresh;
file_refresh = args->file_refresh;
@ -609,7 +606,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 *) xmalloc(sizeof(dav_stat));
fs_stat = (dav_stat *) ne_malloc(sizeof(dav_stat));

fs_stat->blocks = 333333333;
fs_stat->bavail = 133333333;
@ -630,13 +627,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 = xstrdup("");
root->name = ne_strdup("");
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 = xstrdup(args->backup_dir);
backup->name = ne_strdup(args->backup_dir);
backup->mode = S_IFDIR | S_IRWXU;

clean_cache();
@ -677,7 +674,8 @@ dav_close_cache(volatile int *got_sigterm)

clean_tree(root, got_sigterm);

char *new_index = xasprintf("%s/%s.new",cache_dir, DAV_INDEX);
char *new_index = NULL;
if (asprintf(&new_index, "%s/%s.new",cache_dir, DAV_INDEX) < 0) abort();
if (debug)
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "Creating index %s.",
new_index);
@ -695,7 +693,8 @@ dav_close_cache(volatile int *got_sigterm)
if (debug)
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG),
"Replacing old index");
char *old_index = xasprintf("%s/%s", cache_dir, DAV_INDEX);
char *old_index = NULL;
if (asprintf(&old_index, "%s/%s", cache_dir, DAV_INDEX) < 0) abort();
if (rename(new_index, old_index) != 0)
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_ERR),
_("can't replace %s with %s"), old_index, new_index);
@ -911,12 +910,13 @@ dav_create(dav_node **nodep, dav_node *parent, const char *name, uid_t uid,
return EINVAL;

char *name_conv = dav_conv_to_server_enc(name);
char *path = xasprintf("%s%s", parent->path, name_conv);
char *path = NULL;
if (asprintf(&path, "%s%s", parent->path, name_conv) < 0) abort();
free(name_conv);

*nodep = new_node(parent, mode | S_IFREG);
(*nodep)->path = path;
(*nodep)->name = xstrdup(name);
(*nodep)->name = ne_strdup(name);
(*nodep)->uid = uid;
if (grpid && parent->gid != 0) {
(*nodep)->gid = parent->gid;
@ -1038,14 +1038,15 @@ dav_mkdir(dav_node **nodep, dav_node *parent, const char *name, uid_t uid,
return EINVAL;

char *name_conv = dav_conv_to_server_enc(name);
char *path = xasprintf("%s%s/", parent->path, name_conv);
char *path = NULL;
if (asprintf(&path, "%s%s/", parent->path, name_conv) < 0) abort();
free(name_conv);
int ret = dav_make_collection(path);

if (!ret) {
*nodep = new_node(parent, mode | S_IFDIR);
(*nodep)->path = path;
(*nodep)->name = xstrdup(name);
(*nodep)->name = ne_strdup(name);
(*nodep)->uid = uid;
if (grpid && parent->gid != 0) {
(*nodep)->gid = parent->gid;
@ -1571,7 +1572,7 @@ add_to_changed(dav_node *node)
return;
chp = &(*chp)->next;
}
*chp = (dav_node_list_item *) xmalloc(sizeof(dav_node_list_item));
*chp = (dav_node_list_item *) ne_malloc(sizeof(dav_node_list_item));
(*chp)->node = node;
(*chp)->next = NULL;
(*chp)->attempts = 0;
@ -1591,7 +1592,7 @@ backup_node(dav_node *orig)
if (!orig->cache_path)
return;
dav_node *node = new_node(backup, orig->mode);
node->name = xstrdup(orig->cache_path + strlen(cache_dir) +1);
node->name = ne_strdup(orig->cache_path + strlen(cache_dir) +1);
node->cache_path = orig->cache_path;
orig->cache_path = NULL;
orig->dirty = 0;
@ -1776,10 +1777,11 @@ move_dir(dav_node *src, dav_node *dst, dav_node *dst_parent,
char *dst_path;
if (!dst) {
char *dst_conv = dav_conv_to_server_enc(dst_name);
dst_path = xasprintf("%s%s/", dst_parent->path, dst_conv);
dst_path = NULL;
if (asprintf(&dst_path, "%s%s/", dst_parent->path, dst_conv) < 0) abort();
free(dst_conv);
} else {
dst_path = xstrdup(dst->path);
dst_path = ne_strdup(dst->path);
}

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

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

@ -1815,10 +1817,11 @@ move_no_remote(dav_node *src, dav_node *dst, dav_node *dst_parent,
char *dst_path;
if (!dst) {
char *dst_conv = dav_conv_to_server_enc(dst_name);
dst_path = xasprintf("%s%s", dst_parent->path, dst_conv);
dst_path = NULL;
if (asprintf(&dst_path, "%s%s", dst_parent->path, dst_conv) < 0) abort();
free(dst_conv);
} else {
dst_path = xstrdup(dst->path);
dst_path = ne_strdup(dst->path);
}

if (dst) {
@ -1855,7 +1858,7 @@ move_no_remote(dav_node *src, dav_node *dst, dav_node *dst_parent,
dav_lock(dst_path, &src->lock_expire, &src->remote_exists);

free(src->name);
src->name = xstrdup(dst_name);
src->name = ne_strdup(dst_name);
free(src->path);
src->path = dst_path;
if (src->etag) {
@ -1883,10 +1886,11 @@ move_reg(dav_node *src, dav_node *dst, dav_node *dst_parent,
char *dst_path;
if (!dst) {
char *dst_conv = dav_conv_to_server_enc(dst_name);
dst_path = xasprintf("%s%s", dst_parent->path, dst_conv);
dst_path = NULL;
if (asprintf(&dst_path, "%s%s", dst_parent->path, dst_conv) < 0) abort();
free(dst_conv);
} else {
dst_path = xstrdup(dst->path);
dst_path = ne_strdup(dst->path);
}

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

free(src->name);
src->name = xstrdup(dst_name);
src->name = ne_strdup(dst_name);
free(src->path);
src->path = dst_path;
src->utime = time(NULL);
@ -1936,7 +1940,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 *) xmalloc(sizeof(dav_node));
dav_node *node = (dav_node *) ne_malloc(sizeof(dav_node));

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

if (strcmp(node->name, props->name) != 0) {
free(node->name);
node->name = xstrdup(props->name);
node->name = ne_strdup(props->name);
ret = 1;
}

@ -2287,7 +2291,9 @@ update_path(dav_node *node, const char *src_path, const char *dst_path)
return;
}

char *path = xasprintf("%s%s", dst_path, node->path + strlen(src_path));
char *path = NULL;
if (asprintf(&path, "%s%s", dst_path, node->path + strlen(src_path)) < 0)
abort();
free(node->path);
node->path = path;
}
@ -2441,7 +2447,8 @@ create_cache_file(dav_node *node)
}
}

node->cache_path = xasprintf("%s/%s-XXXXXX", cache_dir, node->name);
if (asprintf(&node->cache_path, "%s/%s-XXXXXX", cache_dir, node->name) < 0)
abort();

int fd = mkstemp(node->cache_path);
if (fd <= 0) {
@ -2475,7 +2482,8 @@ create_dir_cache_file(dav_node *dir)
}
}

dir->cache_path = xasprintf("%s/dir-%s-XXXXXX", cache_dir, dir->name);
if (asprintf(&dir->cache_path, "%s/dir-%s-XXXXXX", cache_dir, dir->name) < 0)
abort();
int fd = mkstemp(dir->cache_path);
if (fd <= 0) {
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_ERR),
@ -2513,7 +2521,7 @@ open_file(int *fd, dav_node *node, int flags)
*fd = open(node->cache_path, flags, node->mode);
if (*fd <= 0)
return EIO;
dav_handle *fh = (dav_handle *) xmalloc(sizeof(dav_handle));
dav_handle *fh = (dav_handle *) ne_malloc(sizeof(dav_handle));
fh->fd = *fd;
fh->flags = O_ACCMODE & flags;
fh->next = node->handles;
@ -2659,8 +2667,9 @@ check_cache_dir(const char *dir, const char *host, const char *path,
struct passwd *pw = getpwuid(default_uid);
if (!pw || !pw->pw_name)
error(EXIT_FAILURE, 0, _("can't read user data base"));
char *dir_name = xasprintf("%s%s%s+%s", host, path, mpoint + 1,
pw->pw_name);
char *dir_name = NULL;
if (asprintf(&dir_name, "%s%s%s+%s", host, path, mpoint + 1,
pw->pw_name) < 0) abort();
*(dir_name + strlen(host) + strlen(path) - 1) = '+';
char *pos = strchr(dir_name, '/');
while (pos) {
@ -2675,7 +2684,7 @@ check_cache_dir(const char *dir, const char *host, const char *path,
struct dirent *de = readdir(tl_dir);
while (de && !cache_dir) {
if (strcmp(de->d_name, dir_name) == 0) {
cache_dir = xasprintf("%s/%s", dir, de->d_name);
if (asprintf(&cache_dir, "%s/%s", dir, de->d_name) < 0) abort();
}
de = readdir(tl_dir);
}
@ -2683,7 +2692,7 @@ check_cache_dir(const char *dir, const char *host, const char *path,
closedir(tl_dir);

if (!cache_dir) {
cache_dir = xasprintf("%s/%s", dir, dir_name);
if (asprintf(&cache_dir, "%s/%s", dir, dir_name) < 0) abort();
if (mkdir(cache_dir, S_IRWXU) != 0)
error(EXIT_FAILURE, 0, _("can't create cache directory %s"),
cache_dir);
@ -2716,7 +2725,8 @@ clean_cache(void)

if (strcmp(de->d_name, ".") != 0 && strcmp(de->d_name, "..") != 0
&& strcmp(de->d_name, DAV_INDEX) != 0) {
char *path = xasprintf("%s/%s", cache_dir, de->d_name);
char *path = NULL;
if (asprintf(&path, "%s/%s", cache_dir, de->d_name) < 0) abort();
int i = 0;
dav_node *node = NULL;
while (!node && i < table_size) {
@ -2734,7 +2744,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 = xstrdup(de->d_name);
found->name = ne_strdup(de->d_name);
attr_from_cache_file(found);
backup->mtime = time(NULL);
backup->ctime = backup->mtime;
@ -2757,14 +2767,15 @@ clean_cache(void)
static void
parse_index(void)
{
char *index = xasprintf("%s/%s", cache_dir, DAV_INDEX);
char *index = NULL;
if (asprintf(&index, "%s/%s", cache_dir, DAV_INDEX) < 0) abort();
FILE *idx = fopen(index, "r");
if (!idx) {
free(index);
return;
}

char *buf = xmalloc(DAV_XML_BUF_SIZE);
char *buf = ne_malloc(DAV_XML_BUF_SIZE);
size_t len = fread(buf, 1, DAV_XML_BUF_SIZE, idx);
if (len <= 0) {
free(buf);
@ -2900,7 +2911,8 @@ write_node(dav_node *node, FILE *file, const char *indent)
return -1;
}

char *ind = xasprintf("%s ", indent);
char *ind = NULL;
if (asprintf(&ind, "%s ", indent) < 0) abort();

if (node != root && !is_backup(node)) {
if (fprintf(file, "%s<d:%s><![CDATA[%s]]></d:%s>\n", ind, type[PATH], node->path,
@ -3026,10 +3038,11 @@ static int
xml_cdata(void *userdata, int state, const char *cdata, size_t len)
{
if (!xml_data) {
xml_data = xstrndup(cdata, len);
xml_data = ne_strndup(cdata, len);
} else {
char *add = xstrndup(cdata, len);
char *new = xasprintf("%s%s", xml_data, add);
char *add = ne_strndup(cdata, len);
char *new = NULL;
if (asprintf(&new, "%s%s", xml_data, add) < 0) abort();
free(add);
free(xml_data);
xml_data = new;

View File

@ -1,5 +1,5 @@
/* dav_fuse.c: interface to the fuse kernel module FUSE_KERNEL_VERSION 7.
Copyright (C) 2006, 2007, 2008. 2009 Werner Baumann
Copyright (C) 2006, 2007, 2008. 2009, 2020 Werner Baumann

This file is part of davfs2.

@ -60,9 +60,6 @@
#endif
#include <sys/wait.h>

#include "xalloc.h"
#include "xvasprintf.h"

#include <ne_ssl.h>

#include "defaults.h"
@ -233,7 +230,8 @@ dav_init_kernel_interface(const char *url, const char *mpoint,
if (idle_time > args->lock_refresh / 2)
idle_time = args->lock_refresh / 2;

char *path = xasprintf("%s/%s", DAV_DEV_DIR, FUSE_DEV_NAME);
char *path = NULL;
if (asprintf(&path, "%s/%s", DAV_DEV_DIR, FUSE_DEV_NAME) < 0) abort();

fuse_device = open(path, O_RDWR | O_NONBLOCK);

@ -268,10 +266,11 @@ dav_init_kernel_interface(const char *url, const char *mpoint,
if (fuse_device <= 0)
error(EXIT_FAILURE, 0, _("can't open fuse device"));

char *mdata = xasprintf("fd=%i,rootmode=%o,user_id=%i,group_id=%i,"
"allow_other,max_read=%lu", fuse_device,
args->dir_mode, args->fsuid, args->fsgid,
(unsigned long int) (buf_size - 1024));
char *mdata = NULL;
if (asprintf(&mdata, "fd=%i,rootmode=%o,user_id=%i,group_id=%i,"
"allow_other,max_read=%lu", fuse_device, args->dir_mode,
args->fsuid, args->fsgid,
(unsigned long int) (buf_size - 1024)) < 0) abort();

if (mount(url, mpoint, "fuse", args->mopts, mdata) != 0)
error(EXIT_FAILURE, errno, _("mounting failed"));

View File

@ -75,11 +75,7 @@
#include <sys/types.h>
#endif

#include "canonicalize.h"
#include "xalloc.h"
#include "xvasprintf.h"
#include "xstrndup.h"

#include <ne_alloc.h>
#include <ne_ssl.h>
#include <ne_uri.h>
#include <ne_utils.h>
@ -474,7 +470,9 @@ check_dirs(dav_args *args)
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "mounts in: %s", mounts);

if (!args->use_utab) {
char *utab_dir = xasprintf("%s/%s", DAV_LOCALSTATE_DIR, DAV_UTAB_DIR);
char *utab_dir;
if (asprintf(&utab_dir, "%s/%s", DAV_LOCALSTATE_DIR, DAV_UTAB_DIR) < 0)
abort();
if (stat(utab_dir, &st) != 0) {
gain_privileges(args);
if (mkdir(utab_dir, S_IRWXU | S_IRGRP | S_IXGRP
@ -513,7 +511,7 @@ check_dirs(dav_args *args)
}
release_privileges(args);

fname = xasprintf("%s/%s", DAV_SYS_CONF_DIR, DAV_SECRETS);
if (asprintf(&fname, "%s/%s", DAV_SYS_CONF_DIR, DAV_SECRETS) < 0) abort();
if (stat(fname, &st) == 0) {
if (st.st_uid != 0)
error(EXIT_FAILURE, 0, _("file %s has wrong owner"), fname);
@ -526,38 +524,47 @@ check_dirs(dav_args *args)

if (!args->privileged) {

char *path = xasprintf("%s/.%s", args->home, PACKAGE);
char *path;
if (asprintf(&path, "%s/.%s", args->home, PACKAGE) < 0) abort();
if (stat(path, &st) != 0)
mkdir(path, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);

if (stat(path, &st) == 0) {
fname = xasprintf("%s/.%s/%s", args->home, PACKAGE, DAV_CACHE);
if (asprintf(&fname, "%s/.%s/%s", args->home, PACKAGE, DAV_CACHE) < 0)
abort();
if (stat(fname, &st) != 0)
mkdir(fname, S_IRWXU);
free(fname);

fname = xasprintf("%s/.%s/%s", args->home, PACKAGE, DAV_CERTS_DIR);
if (asprintf(&fname, "%s/.%s/%s", args->home, PACKAGE,
DAV_CERTS_DIR) < 0) abort();
if (stat(fname, &st) != 0)
mkdir(fname, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
free(fname);

fname = xasprintf("%s/.%s/%s/%s", args->home, PACKAGE,
DAV_CERTS_DIR, DAV_CLICERTS_DIR);
if (asprintf(&fname, "%s/.%s/%s/%s", args->home, PACKAGE,
DAV_CERTS_DIR, DAV_CLICERTS_DIR) < 0) abort();
if (stat(fname, &st) != 0)
mkdir(fname, S_IRWXU);
free(fname);

fname = xasprintf("%s/.%s/%s", args->home, PACKAGE, DAV_CONFIG);
if (asprintf(&fname, "%s/.%s/%s", args->home, PACKAGE, DAV_CONFIG) < 0)
abort();
if (stat(fname, &st) != 0) {
char *template = xasprintf("%s/%s", DAV_DATA_DIR, DAV_CONFIG);
char *template;
if (asprintf(&template, "%s/%s", DAV_DATA_DIR, DAV_CONFIG) < 0)
abort();
cp_file(template, fname);
free(template);
}
free(fname);

fname = xasprintf("%s/.%s/%s", args->home, PACKAGE, DAV_SECRETS);
if (asprintf(&fname, "%s/.%s/%s", args->home, PACKAGE,
DAV_SECRETS) < 0) abort();
if (stat(fname, &st) != 0) {
char *template = xasprintf("%s/%s", DAV_DATA_DIR, DAV_SECRETS);
char *template;
if (asprintf(&template, "%s/%s", DAV_DATA_DIR, DAV_SECRETS) < 0)
abort();
cp_file(template, fname);
chmod(fname, S_IRUSR | S_IWUSR);
free(template);
@ -659,13 +666,14 @@ check_double_mounts(dav_args *args)
char *m = mpoint;
while (*m == '/')
m++;
char *mp = xstrdup(m);
char *mp = ne_strdup(m);
m = strchr(mp, '/');
while (m) {
*m = '-';
m = strchr(mp, '/');
}
char *pidf = xasprintf("%s/%s.pid", DAV_SYS_RUN, mp);
char *pidf;
if (asprintf(&pidf, "%s/%s.pid", DAV_SYS_RUN, mp) < 0) abort();
free(mp);
if (debug)
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "PID file: %s", pidf);
@ -837,7 +845,7 @@ parse_commandline(dav_args *args, int argc, char *argv[])
int i;
for (i = 0; i < argc; i++)
len += strlen(argv[i]);
args->cmdline = xmalloc(len);
args->cmdline = ne_malloc(len);
char *p = args->cmdline;
for (i = 0; i < argc - 1; i++) {
strcpy(p, argv[i]);
@ -893,9 +901,9 @@ parse_commandline(dav_args *args, int argc, char *argv[])
exit(EXIT_FAILURE);
case 2:
if (*argv[i] == '\"' || *argv[i] == '\'') {
url = xstrndup(argv[i] + 1, strlen(argv[i]) - 2);
url = ne_strndup(argv[i] + 1, strlen(argv[i]) - 2);
} else {
url = xstrdup(argv[i]);
url = ne_strdup(argv[i]);
}
i++;
mpoint = canonicalize_file_name(argv[i]);
@ -939,14 +947,15 @@ parse_config(dav_args *args)
if (args->conf) {
expand_home(&args->conf, args);
} else if (!args->privileged) {
args->conf = xasprintf("%s/.%s/%s", args->home, PACKAGE, DAV_CONFIG);
if (asprintf(&args->conf, "%s/.%s/%s", args->home, PACKAGE,
DAV_CONFIG) < 0) abort();
}

if (args->conf)
read_config(args, args->conf, 0);

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

if (!args->dav_group)
args->dav_group = xstrdup(DAV_GROUP);
args->dav_group = ne_strdup(DAV_GROUP);
struct group *grp = getgrnam(args->dav_group);
if (!grp)
error(EXIT_FAILURE, errno, _("group %s does not exist"),
@ -973,8 +982,8 @@ parse_config(dav_args *args)
if (args->secrets)
expand_home(&args->secrets, args);
if (!args->privileged && !args->secrets)
args->secrets = xasprintf("%s/.%s/%s", args->home, PACKAGE,
DAV_SECRETS);
if (asprintf(&args->secrets, "%s/.%s/%s", args->home, PACKAGE,
DAV_SECRETS) < 0) abort();

if (args->clicert) {
args->client_cert = read_client_cert(&args->clicert, args, 0);
@ -992,20 +1001,20 @@ parse_config(dav_args *args)
args->useproxy = 0;

if (!args->sys_cache)
args->sys_cache = xstrdup(DAV_SYS_CACHE);
args->sys_cache = ne_strdup(DAV_SYS_CACHE);
if (args->privileged) {
args->cache_dir = xstrdup(args->sys_cache);
args->cache_dir = ne_strdup(args->sys_cache);
} else {
if (args->cache_dir) {
expand_home(&args->cache_dir, args);
} else {
args->cache_dir = xasprintf("%s/.%s/%s", args->home, PACKAGE,
DAV_CACHE);
if (asprintf(&args->cache_dir, "%s/.%s/%s", args->home, PACKAGE,
DAV_CACHE) < 0) abort();
}
}

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

if (!args->delay_upload)
args->delay_upload = DAV_DELAY_UPLOAD;
@ -1034,13 +1043,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 = xstrdup(pw->pw_name);
args->uid_name = ne_strdup(pw->pw_name);
args->home = canonicalize_file_name(pw->pw_dir);
}

args->ngroups = getgroups(0, NULL);
if (args->ngroups) {
args->groups = (gid_t *) xmalloc(args->ngroups * sizeof(gid_t));
args->groups = (gid_t *) ne_malloc(args->ngroups * sizeof(gid_t));
if (getgroups(args->ngroups, args->groups) < 0)
error(EXIT_FAILURE, 0, _("can't read group data base"));
}
@ -1209,35 +1218,37 @@ write_mtab_entry(const dav_args *args)
char *lock_file = NULL;

if (args->use_utab) {
utab_line = xasprintf("SRC=%s TARGET=%s ROOT=/ "
"OPTS=uid=%i,gid=%i%s%s%s,helper=%s\n",
url, mpoint, args->fsuid, args->fsgid,
(args->grpid) ? ",grpid" : "",
(!args->privileged) ? ",user=" : "",
(!args->privileged) ? args->uid_name : "",
DAV_FS_TYPE);
tab_file = xasprintf("%s/%s/%s", DAV_LOCALSTATE_DIR, DAV_UTAB_DIR,
DAV_UTAB);
lock_file = xasprintf("%s,lock", tab_file);
if (asprintf(&utab_line,
"SRC=%s TARGET=%s ROOT=/ "
"OPTS=uid=%i,gid=%i%s%s%s,helper=%s\n",
url, mpoint, args->fsuid, args->fsgid,
(args->grpid) ? ",grpid" : "",
(!args->privileged) ? ",user=" : "",
(!args->privileged) ? args->uid_name : "",
DAV_FS_TYPE) < 0) abort();
if (asprintf(&tab_file, "%s/%s/%s", DAV_LOCALSTATE_DIR, DAV_UTAB_DIR,
DAV_UTAB) < 0) abort();
if (asprintf(&lock_file, "%s,lock", tab_file) < 0) abort();

} else {
mntent.mnt_fsname = url;
mntent.mnt_dir = mpoint;
mntent.mnt_type = DAV_FS_TYPE;
mntent.mnt_opts = xasprintf("%s%s%s%s%s%s,uid=%i,gid=%i%s%s",
(args->mopts & MS_RDONLY) ? "ro" : "rw",
(args->mopts & MS_NOSUID) ? ",nosuid" : "",
(args->mopts & MS_NOEXEC) ? ",noexec" : "",
(args->mopts & MS_NODEV) ? ",nodev" : "",
(args->grpid) ? ",grpid" : "",
(args->netdev) ? ",_netdev" : "",
args->fsuid, args->fsgid,
(!args->privileged) ? ",user=" : "",
(!args->privileged) ? args->uid_name : "");
if (asprintf(&mntent.mnt_opts,
"%s%s%s%s%s%s,uid=%i,gid=%i%s%s",
(args->mopts & MS_RDONLY) ? "ro" : "rw",
(args->mopts & MS_NOSUID) ? ",nosuid" : "",
(args->mopts & MS_NOEXEC) ? ",noexec" : "",
(args->mopts & MS_NODEV) ? ",nodev" : "",
(args->grpid) ? ",grpid" : "",
(args->netdev) ? ",_netdev" : "",
args->fsuid, args->fsgid,
(!args->privileged) ? ",user=" : "",
(!args->privileged) ? args->uid_name : "") < 0) abort();
mntent. mnt_freq = 0;
mntent. mnt_passno = 0;
tab_file = xstrdup(_PATH_MOUNTED);
lock_file = xasprintf("%s~", tab_file);
tab_file = ne_strdup(_PATH_MOUNTED);
if (asprintf(&lock_file, "%s~", tab_file) < 0) abort();
}

sigset_t oldset;
@ -1502,7 +1513,8 @@ expand_home(char **dir, const dav_args *args)
if (*p != '/')
return;

char *new_dir = xasprintf("%s%s", args->home, p);
char *new_dir;
if (asprintf(&new_dir, "%s%s", args->home, p) < 0) abort();
free(*dir);
*dir = new_dir;
}
@ -1597,12 +1609,12 @@ get_options(dav_args *args, char *option)
case CONF:
if (args->conf)
free(args->conf);
args->conf = xstrdup(argument);
args->conf = ne_strdup(argument);
break;
case USERNAME:
if (args->cl_username)
free(args->cl_username);
args->cl_username = xstrdup(argument);
args->cl_username = ne_strdup(argument);
break;
case UID:
pwd = getpwnam(argument);
@ -1698,7 +1710,7 @@ get_options(dav_args *args, char *option)
static dav_args *
new_args(void)
{
dav_args *args = (dav_args *) xcalloc(1, sizeof(dav_args));
dav_args *args = (dav_args *) ne_calloc(sizeof(dav_args));

args->netdev = DAV_NETDEV;
args->grpid = DAV_GRPID;
@ -2055,14 +2067,14 @@ read_cert(char **filename, dav_args *args)
} else {
char *f = NULL;
if (!args->privileged) {
f = xasprintf("%s/.%s/%s/%s", args->home, PACKAGE,
DAV_CERTS_DIR, *filename);
if (asprintf(&f, "%s/.%s/%s/%s", args->home, PACKAGE,
DAV_CERTS_DIR, *filename) < 0) abort();
cert = ne_ssl_cert_read(f);
}
if (!cert) {
if (f) free(f);
f = xasprintf("%s/%s/%s", DAV_SYS_CONF_DIR, DAV_CERTS_DIR,
*filename);
if (asprintf(&f, "%s/%s/%s", DAV_SYS_CONF_DIR, DAV_CERTS_DIR,
*filename) < 0) abort();
cert = ne_ssl_cert_read(f);
}
if (cert) {
@ -2091,11 +2103,11 @@ read_client_cert(char **filename, dav_args *args, int system)
if (**filename != '/') {
char *f = NULL;
if (!system) {
f = xasprintf("%s/.%s/%s/%s/%s", args->home, PACKAGE,
DAV_CERTS_DIR, DAV_CLICERTS_DIR, *filename);
if (asprintf(&f, "%s/.%s/%s/%s/%s", args->home, PACKAGE,
DAV_CERTS_DIR, DAV_CLICERTS_DIR, *filename) < 0) abort();
} else {
f = xasprintf("%s/%s/%s/%s", DAV_SYS_CONF_DIR, DAV_CERTS_DIR,
DAV_CLICERTS_DIR, *filename);
if (asprintf(&f, "%s/%s/%s/%s", DAV_SYS_CONF_DIR, DAV_CERTS_DIR,
DAV_CLICERTS_DIR, *filename) < 0) abort();
}
free(*filename);
*filename = f;
@ -2169,33 +2181,33 @@ 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 = xstrdup(parmv[1]);
args->dav_user = ne_strdup(parmv[1]);
} else if (system && strcmp(parmv[0], "dav_group") == 0) {
if (args->dav_group)
free(args->dav_group);
args->dav_group = xstrdup(parmv[1]);
args->dav_group = ne_strdup(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], "trust_ca_cert") == 0) {
if (args->trust_ca_cert)
free(args->trust_ca_cert);
args->trust_ca_cert = xstrdup(parmv[1]);
args->trust_ca_cert = ne_strdup(parmv[1]);
} else if (strcmp(parmv[0], "trust_server_cert") == 0) {
if (args->trust_server_cert)
free(args->trust_server_cert);
args->trust_server_cert = xstrdup(parmv[1]);
args->trust_server_cert = ne_strdup(parmv[1]);
} else if (!system && strcmp(parmv[0], "secrets") == 0) {
if (args->secrets)
free(args->secrets);
args->secrets = xstrdup(parmv[1]);
args->secrets = ne_strdup(parmv[1]);
} else if (!system && strcmp(parmv[0], "clientcert") == 0) {
if (args->clicert)
free(args->clicert);
args->clicert = xstrdup(parmv[1]);
args->clicert = ne_strdup(parmv[1]);
} else if (system && strcmp(parmv[0], "clientcert") == 0) {
if (args->sys_clicert)
free(args->sys_clicert);
args->sys_clicert = xstrdup(parmv[1]);
args->sys_clicert = ne_strdup(parmv[1]);
} else if (system && strcmp(parmv[0], "proxy") == 0) {
if (split_uri(NULL, &args->p_host, &args->p_port, NULL,
parmv[1]) != 0)
@ -2210,7 +2222,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 = xstrdup(parmv[1]);
args->lock_owner = ne_strdup(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) {
@ -2251,19 +2263,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 = xstrdup(parmv[1]);
args->s_charset = ne_strdup(parmv[1]);
} else if (system && strcmp(parmv[0], "cache_dir") == 0) {
if (args->sys_cache)
free(args->sys_cache);
args->sys_cache = xstrdup(parmv[1]);
args->sys_cache = ne_strdup(parmv[1]);
} else if (!system && strcmp(parmv[0], "cache_dir") == 0) {
if (args->cache_dir != NULL)
free(args->cache_dir);
args->cache_dir = xstrdup(parmv[1]);
args->cache_dir = ne_strdup(parmv[1]);
} else if (strcmp(parmv[0], "backup_dir") == 0) {
if (args->backup_dir)
free(args->backup_dir);
args->backup_dir = xstrdup(parmv[1]);
args->backup_dir = ne_strdup(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) {
@ -2291,11 +2303,12 @@ read_config(dav_args *args, const char * filename, int system)
if (strcmp(parmv[0], "add_header") == 0) {
if (args->header) {
char *tmp = args->header;
args->header = xasprintf("%s: %s\r\n%s", parmv[1],
parmv[2], tmp);
if (asprintf(&args->header, "%s: %s\r\n%s", parmv[1],
parmv[2], tmp) < 0) abort();
if (tmp) free(tmp);
} else {
args->header = xasprintf("%s: %s\r\n", parmv[1], parmv[2]);
if (asprintf(&args->header, "%s: %s\r\n", parmv[1],
parmv[2]) < 0) abort();
}
} else {
error_at_line(EXIT_FAILURE, 0, filename, lineno,
@ -2336,15 +2349,15 @@ read_no_proxy_list(dav_args *args)
return;
}

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

char *host = NULL;
if (strchr(np, ':')) {
host = xasprintf("%s:%d", args->host, args->port);
if (asprintf(&host, "%s:%d", args->host, args->port) < 0) abort();
} else {
host = xstrdup(args->host);
host = ne_strdup(args->host);
}

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

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

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

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

if (scheme) free(scheme);
@ -2561,9 +2574,9 @@ split_uri(char **scheme, char **host, int *port,char **path, const char *uri)
if (scheme) {
if (*scheme) free(*scheme);
if (sch) {
*scheme = xstrdup(sch);
*scheme = ne_strdup(sch);
} else {
*scheme = xstrdup("http");
*scheme = ne_strdup("http");
}
}

@ -2572,7 +2585,7 @@ split_uri(char **scheme, char **host, int *port,char **path, const char *uri)

if (host) {
if (*host) free(*host);
*host = xmalloc(end - ho + 1);
*host = ne_malloc(end - ho + 1);
int i;
for (i = 0; i < (end - ho); i++) {
if (*ho == '[') {
@ -2589,11 +2602,11 @@ split_uri(char **scheme, char **host, int *port,char **path, const char *uri)
if (path) {
if (*path) free(*path);
if (!*pa) {
*path = xstrdup("/");
*path = ne_strdup("/");
} else if (*(pa + strlen(pa) - 1) == '/') {
*path = xstrdup(pa);
*path = ne_strdup(pa);
} else {
*path = xasprintf("%s/", pa);
if (asprintf(path, "%s/", pa) < 0) abort();
}
}


View File

@ -40,11 +40,9 @@
#include <unistd.h>
#endif

#include "xalloc.h"
#include "xvasprintf.h"
#include <ne_alloc.h>

#include "defaults.h"
#include "canonicalize.h"

#ifdef ENABLE_NLS
#define _(String) gettext(String)
@ -126,9 +124,9 @@ main(int argc, char *argv[])

char *umount_command = NULL;
if (mpoint) {
umount_command = xasprintf("umount -i '%s'", mpoint);
if (asprintf(&umount_command, "umount -i '%s'", mpoint) < 0) abort();
} else {
umount_command = xasprintf("umount -i '%s'", argv[optind]);
if (asprintf(&umount_command, "umount -i '%s'", argv[optind]) < 0) abort();
error(0, 0,
_("\n"
" can't evaluate PID file name;\n"
@ -140,13 +138,14 @@ main(int argc, char *argv[])
char *m = mpoint;
while (*m == '/')
m++;
char *mp = xstrdup(m);
char *mp = ne_strdup(m);
m = strchr(mp, '/');
while (m) {
*m = '-';
m = strchr(mp, '/');
}
char *pidfile = xasprintf("%s/%s.pid", DAV_SYS_RUN, mp);
char *pidfile;
if (asprintf(&pidfile, "%s/%s.pid", DAV_SYS_RUN, mp) < 0) abort();
free(mp);

char *pid = NULL;
@ -161,7 +160,8 @@ main(int argc, char *argv[])
}
fclose(file);

char *ps_command = xasprintf("ps -p %s", pid);
char *ps_command;
if (asprintf(&ps_command, "ps -p %s", pid) < 0) abort();
FILE *ps_in = popen(ps_command, "r");
if (!ps_in) {
error(0, 0,

View File

@ -1,5 +1,5 @@
/* webdav.c: send requests to the WebDAV server.
Copyright (C) 2006, 2007, 2008, 2009 Werner Baumann
Copyright (C) 2006, 2007, 2008, 2009, 2020 Werner Baumann

This file is part of davfs2.

@ -59,10 +59,7 @@
#include <sys/stat.h>
#endif

#include "xalloc.h"
#include "xstrndup.h"
#include "xvasprintf.h"

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

if (args->neon_debug & ~NE_DBG_HTTPPLAIN) {
char *buf = xmalloc(log_bufsize);
cookie_io_functions_t *log_func = xmalloc(sizeof(cookie_io_functions_t));
char *buf = ne_malloc(log_bufsize);
cookie_io_functions_t *log_func = ne_malloc(sizeof(cookie_io_functions_t));
log_func->read = NULL;
log_func->write = log_writer;
log_func->seek = NULL;
@ -375,7 +372,9 @@ dav_init_webdav(dav_args *args)

ne_set_connect_timeout(session, args->connect_timeout);

char *useragent = xasprintf("%s/%s", PACKAGE_TARNAME, PACKAGE_VERSION);
char *useragent = NULL;
if (asprintf(&useragent, "%s/%s", PACKAGE_TARNAME, PACKAGE_VERSION) < 0)
abort();
ne_set_useragent(session, useragent);
free(useragent);

@ -385,17 +384,17 @@ dav_init_webdav(dav_args *args)
#endif

if (args->username)
username = xstrdup(args->username);
username = ne_strdup(args->username);
if (args->password)
password = xstrdup(args->password);
password = ne_strdup(args->password);
ne_add_server_auth(session, NE_AUTH_ALL, auth, "server");

if (args->useproxy && args->p_host) {
ne_session_proxy(session, args->p_host, args->p_port);
if (args->p_user)
p_username = xstrdup(args->p_user);
p_username = ne_strdup(args->p_user);
if (args->p_passwd)
p_password = xstrdup(args->p_passwd);
p_password = ne_strdup(args->p_passwd);
ne_add_proxy_auth(session, NE_AUTH_ALL, auth, "proxy");
}

@ -423,23 +422,23 @@ dav_init_webdav(dav_args *args)
locks = ne_lockstore_create();
if (!args->lock_owner) {
if (!args->username) {
owner = xstrdup(PACKAGE_STRING);
owner = ne_strdup(PACKAGE_STRING);
} else {
owner = xstrdup(args->username);
owner = ne_strdup(args->username);
}
} else {
owner = xstrdup(args->lock_owner);
owner = ne_strdup(args->lock_owner);
}
lock_timeout = args->lock_timeout;
}

if (args->header) {
custom_header = xstrdup(args->header);
custom_header = ne_strdup(args->header);
}

if (args->n_cookies) {
n_cookies = args->n_cookies;
cookie_list = (char **) xcalloc(n_cookies, sizeof(char *));
cookie_list = (char **) ne_calloc(n_cookies * sizeof(char *));
ne_hook_post_headers(session, get_cookies, NULL);
}

@ -526,7 +525,7 @@ dav_close_webdav(void)
char *
dav_conv_from_utf_8(const char *s)
{
char *new = xstrdup(s);
char *new = ne_strdup(s);
#if defined DAV_USE_ICONV && defined HAVE_ICONV_H
if (from_utf_8)
convert(&new, from_utf_8);
@ -538,7 +537,7 @@ dav_conv_from_utf_8(const char *s)
char *
dav_conv_to_utf_8(const char *s)
{
char *new = xstrdup(s);
char *new = ne_strdup(s);
#if defined DAV_USE_ICONV && defined HAVE_ICONV_H
if (to_utf_8)
convert(&new, to_utf_8);
@ -550,7 +549,7 @@ dav_conv_to_utf_8(const char *s)
char *
dav_conv_from_server_enc(const char *s)
{
char *new = xstrdup(s);
char *new = ne_strdup(s);
#if defined DAV_USE_ICONV && defined HAVE_ICONV_H
if (from_server_enc)
convert(&new, from_server_enc);
@ -562,7 +561,7 @@ dav_conv_from_server_enc(const char *s)
char *
dav_conv_to_server_enc(const char *s)
{
char *new = xstrdup(s);
char *new = ne_strdup(s);
#if defined DAV_USE_ICONV && defined HAVE_ICONV_H
if (to_server_enc)
convert(&new, to_server_enc);
@ -827,7 +826,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 = xstrdup(owner);
lock->owner = ne_strdup(owner);
lock->timeout = lock_timeout;

if (!has_if_match_bug && !*exists)
@ -1160,7 +1159,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 = xcalloc(outsize, 1);
char *buf = ne_calloc(outsize);
char *out = buf;

iconv(conv, NULL, NULL, &out, &outsize);
@ -1168,7 +1167,7 @@ convert(char **s, iconv_t conv)
&& insize == 0 && outsize >= MB_LEN_MAX) {
memset(out, 0, MB_LEN_MAX);
free(*s);
*s = xstrndup(buf, out - buf + MB_LEN_MAX);
*s = ne_strndup(buf, out - buf + MB_LEN_MAX);
}

free(buf);
@ -1441,11 +1440,11 @@ replace_slashes(char **name)
char *nn;
*slash = '\0';
if (slash == *name) {
nn = xasprintf("slash-%s", slash + 1);
if (asprintf(&nn, "slash-%s", slash + 1) < 0) abort();
} else if (slash == end) {
nn = xasprintf("%s-slash", *name);
if (asprintf(&nn, "%s-slash", *name) < 0) abort();
} else {
nn = xasprintf("%s-slash-%s", *name, slash + 1);
if (asprintf(&nn, "%s-slash-%s", *name, slash + 1) < 0) abort();
}
free(*name);
*name = nn;
@ -1577,9 +1576,9 @@ get_cookies(ne_request *req, void *userdata, const ne_status *status)
char *s;
const char *end = strchr(value, ';');
if (end) {
s = xstrndup(value, end - value);
s = ne_strndup(value, end - value);
} else {
s = xstrdup(value);
s = ne_strdup(value);
}
char *es = strchr(s, '=');
if (!es) {
@ -1598,12 +1597,12 @@ get_cookies(ne_request *req, void *userdata, const ne_status *status)
int i = 0;
for (i = 0; i < n_cookies; i++) {
if (!cookie_list[i]) {
cookie_list[i] = xstrdup(cookie);
cookie_list[i] = ne_strdup(cookie);
break;
}
if (strncmp(cookie_list[i], cookie, nl) == 0) {
free(cookie_list[i]);
cookie_list[i] = xstrdup(cookie);
cookie_list[i] = ne_strdup(cookie);
break;
}
}
@ -1664,7 +1663,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 *) xmalloc(strlen(uri->path) + 1);
char *tmp_path = (char *) ne_malloc(strlen(uri->path) + 1);
const char *from = uri->path;
char *to = tmp_path;
while (*from) {
@ -1673,7 +1672,7 @@ prop_result(void *userdata, const ne_uri *uri, const ne_prop_result_set *set)
*to++ = *from++;
}
*to = 0;
dav_props *result = xcalloc(1, sizeof(dav_props));
dav_props *result = ne_calloc(sizeof(dav_props));
result->path = ne_path_unescape(tmp_path);
free (tmp_path);

@ -1695,7 +1694,8 @@ prop_result(void *userdata, const ne_uri *uri, const ne_prop_result_set *set)
*(result->path + strlen(result->path) - 1) = '\0';
} else {
if (result->is_dir) {
char *tmp = xasprintf("%s/", result->path);
char *tmp = NULL;
if (asprintf(&tmp, "%s/", result->path) < 0) abort();
free(result->path);
result->path = tmp;
}
@ -1707,13 +1707,13 @@ prop_result(void *userdata, const ne_uri *uri, const ne_prop_result_set *set)
}

if (strcasecmp(result->path, ctx->path) == 0) {
result->name = xstrdup("");
result->name = ne_strdup("");
} else {
if (strlen(result->path) < (strlen(ctx->path) + result->is_dir + 1)) {
dav_delete_props(result);
return;
}
result->name = xstrndup(result->path + strlen(ctx->path),
result->name = ne_strndup(result->path + strlen(ctx->path),
strlen(result->path) - strlen(ctx->path)
- result->is_dir);
replace_slashes(&result->name);
@ -1810,7 +1810,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 = xcalloc(1, NE_SSL_DIGESTLEN);
char *digest = ne_calloc(NE_SSL_DIGESTLEN);
if (!issuer || !subject || ne_ssl_cert_digest(cert, digest) != 0) {
if (have_terminal) {
error(0, 0, _("error processing server certificate"));