Add sudo_ prefix to alloc.c functions and rename alloc.h -> sudo_alloc.h
This commit is contained in:
@@ -280,12 +280,12 @@ realclean: distclean
|
||||
cleandir: realclean
|
||||
|
||||
# Autogenerated dependencies, do not modify
|
||||
aix.lo: $(srcdir)/aix.c $(incdir)/alloc.h $(incdir)/compat/stdbool.h \
|
||||
$(incdir)/fatal.h $(incdir)/gettext.h $(incdir)/missing.h \
|
||||
aix.lo: $(srcdir)/aix.c $(incdir)/compat/stdbool.h $(incdir)/fatal.h \
|
||||
$(incdir)/gettext.h $(incdir)/missing.h $(incdir)/sudo_alloc.h \
|
||||
$(incdir)/sudo_debug.h $(incdir)/sudo_util.h $(top_builddir)/config.h
|
||||
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/aix.c
|
||||
alloc.lo: $(srcdir)/alloc.c $(incdir)/alloc.h $(incdir)/fatal.h \
|
||||
$(incdir)/gettext.h $(incdir)/missing.h $(top_builddir)/config.h
|
||||
alloc.lo: $(srcdir)/alloc.c $(incdir)/fatal.h $(incdir)/gettext.h \
|
||||
$(incdir)/missing.h $(incdir)/sudo_alloc.h $(top_builddir)/config.h
|
||||
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/alloc.c
|
||||
atobool.lo: $(srcdir)/atobool.c $(incdir)/compat/stdbool.h $(incdir)/missing.h \
|
||||
$(incdir)/sudo_debug.h $(incdir)/sudo_util.h \
|
||||
@@ -314,25 +314,26 @@ conf_test.lo: $(srcdir)/regress/sudo_conf/conf_test.c \
|
||||
$(incdir)/sudo_conf.h $(incdir)/sudo_util.h \
|
||||
$(top_builddir)/config.h
|
||||
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/regress/sudo_conf/conf_test.c
|
||||
event.lo: $(srcdir)/event.c $(incdir)/alloc.h $(incdir)/compat/stdbool.h \
|
||||
$(incdir)/fatal.h $(incdir)/missing.h $(incdir)/queue.h \
|
||||
event.lo: $(srcdir)/event.c $(incdir)/compat/stdbool.h $(incdir)/fatal.h \
|
||||
$(incdir)/missing.h $(incdir)/queue.h $(incdir)/sudo_alloc.h \
|
||||
$(incdir)/sudo_debug.h $(incdir)/sudo_event.h $(incdir)/sudo_util.h \
|
||||
$(top_builddir)/config.h
|
||||
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/event.c
|
||||
event_poll.lo: $(srcdir)/event_poll.c $(incdir)/alloc.h \
|
||||
$(incdir)/compat/stdbool.h $(incdir)/fatal.h \
|
||||
$(incdir)/missing.h $(incdir)/queue.h $(incdir)/sudo_debug.h \
|
||||
event_poll.lo: $(srcdir)/event_poll.c $(incdir)/compat/stdbool.h \
|
||||
$(incdir)/fatal.h $(incdir)/missing.h $(incdir)/queue.h \
|
||||
$(incdir)/sudo_alloc.h $(incdir)/sudo_debug.h \
|
||||
$(incdir)/sudo_event.h $(top_builddir)/config.h
|
||||
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/event_poll.c
|
||||
event_select.lo: $(srcdir)/event_select.c $(incdir)/alloc.h \
|
||||
$(incdir)/compat/stdbool.h $(incdir)/fatal.h \
|
||||
$(incdir)/missing.h $(incdir)/queue.h $(incdir)/sudo_debug.h \
|
||||
event_select.lo: $(srcdir)/event_select.c $(incdir)/compat/stdbool.h \
|
||||
$(incdir)/fatal.h $(incdir)/missing.h $(incdir)/queue.h \
|
||||
$(incdir)/sudo_alloc.h $(incdir)/sudo_debug.h \
|
||||
$(incdir)/sudo_event.h $(incdir)/sudo_util.h \
|
||||
$(top_builddir)/config.h
|
||||
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/event_select.c
|
||||
fatal.lo: $(srcdir)/fatal.c $(incdir)/alloc.h $(incdir)/compat/stdbool.h \
|
||||
$(incdir)/fatal.h $(incdir)/gettext.h $(incdir)/missing.h \
|
||||
$(incdir)/queue.h $(incdir)/sudo_plugin.h $(top_builddir)/config.h
|
||||
fatal.lo: $(srcdir)/fatal.c $(incdir)/compat/stdbool.h $(incdir)/fatal.h \
|
||||
$(incdir)/gettext.h $(incdir)/missing.h $(incdir)/queue.h \
|
||||
$(incdir)/sudo_alloc.h $(incdir)/sudo_plugin.h \
|
||||
$(top_builddir)/config.h
|
||||
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/fatal.c
|
||||
fnm_test.lo: $(srcdir)/regress/fnmatch/fnm_test.c $(incdir)/compat/fnmatch.h \
|
||||
$(incdir)/missing.h $(top_builddir)/config.h
|
||||
@@ -356,8 +357,8 @@ getline.lo: $(srcdir)/getline.c $(incdir)/missing.h $(top_builddir)/config.h
|
||||
getopt_long.lo: $(srcdir)/getopt_long.c $(incdir)/compat/getopt.h \
|
||||
$(incdir)/fatal.h $(incdir)/missing.h $(top_builddir)/config.h
|
||||
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/getopt_long.c
|
||||
gidlist.lo: $(srcdir)/gidlist.c $(incdir)/alloc.h $(incdir)/compat/stdbool.h \
|
||||
$(incdir)/fatal.h $(incdir)/gettext.h $(incdir)/missing.h \
|
||||
gidlist.lo: $(srcdir)/gidlist.c $(incdir)/compat/stdbool.h $(incdir)/fatal.h \
|
||||
$(incdir)/gettext.h $(incdir)/missing.h $(incdir)/sudo_alloc.h \
|
||||
$(incdir)/sudo_debug.h $(incdir)/sudo_util.h \
|
||||
$(top_builddir)/config.h
|
||||
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/gidlist.c
|
||||
@@ -378,8 +379,8 @@ key_val.lo: $(srcdir)/key_val.c $(incdir)/compat/stdbool.h $(incdir)/missing.h \
|
||||
$(incdir)/sudo_debug.h $(incdir)/sudo_util.h \
|
||||
$(top_builddir)/config.h
|
||||
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/key_val.c
|
||||
lbuf.lo: $(srcdir)/lbuf.c $(incdir)/alloc.h $(incdir)/fatal.h \
|
||||
$(incdir)/missing.h $(incdir)/sudo_debug.h $(incdir)/sudo_lbuf.h \
|
||||
lbuf.lo: $(srcdir)/lbuf.c $(incdir)/fatal.h $(incdir)/missing.h \
|
||||
$(incdir)/sudo_alloc.h $(incdir)/sudo_debug.h $(incdir)/sudo_lbuf.h \
|
||||
$(top_builddir)/config.h
|
||||
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/lbuf.c
|
||||
locale_stub.lo: $(top_srcdir)/src/locale_stub.c $(incdir)/fatal.h \
|
||||
@@ -443,16 +444,16 @@ strsignal.lo: $(srcdir)/strsignal.c $(incdir)/gettext.h $(incdir)/missing.h \
|
||||
strtonum.lo: $(srcdir)/strtonum.c $(incdir)/gettext.h $(incdir)/missing.h \
|
||||
$(top_builddir)/config.h
|
||||
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/strtonum.c
|
||||
sudo_conf.lo: $(srcdir)/sudo_conf.c $(incdir)/alloc.h \
|
||||
$(incdir)/compat/stdbool.h $(incdir)/fatal.h $(incdir)/gettext.h \
|
||||
$(incdir)/missing.h $(incdir)/queue.h $(incdir)/secure_path.h \
|
||||
sudo_conf.lo: $(srcdir)/sudo_conf.c $(incdir)/compat/stdbool.h \
|
||||
$(incdir)/fatal.h $(incdir)/gettext.h $(incdir)/missing.h \
|
||||
$(incdir)/queue.h $(incdir)/secure_path.h $(incdir)/sudo_alloc.h \
|
||||
$(incdir)/sudo_conf.h $(incdir)/sudo_debug.h \
|
||||
$(incdir)/sudo_plugin.h $(incdir)/sudo_util.h \
|
||||
$(top_builddir)/config.h $(top_builddir)/pathnames.h
|
||||
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/sudo_conf.c
|
||||
sudo_debug.lo: $(srcdir)/sudo_debug.c $(incdir)/alloc.h \
|
||||
$(incdir)/compat/stdbool.h $(incdir)/fatal.h \
|
||||
$(incdir)/gettext.h $(incdir)/missing.h $(incdir)/sudo_debug.h \
|
||||
sudo_debug.lo: $(srcdir)/sudo_debug.c $(incdir)/compat/stdbool.h \
|
||||
$(incdir)/fatal.h $(incdir)/gettext.h $(incdir)/missing.h \
|
||||
$(incdir)/sudo_alloc.h $(incdir)/sudo_debug.h \
|
||||
$(incdir)/sudo_plugin.h $(incdir)/sudo_util.h \
|
||||
$(top_builddir)/config.h
|
||||
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/sudo_debug.c
|
||||
|
@@ -35,7 +35,7 @@
|
||||
#include "gettext.h" /* must be included before missing.h */
|
||||
|
||||
#include "missing.h"
|
||||
#include "alloc.h"
|
||||
#include "sudo_alloc.h"
|
||||
#include "fatal.h"
|
||||
#include "sudo_debug.h"
|
||||
#include "sudo_util.h"
|
||||
@@ -187,7 +187,7 @@ aix_prep_user(char *user, const char *tty)
|
||||
debug_decl(aix_setauthdb, SUDO_DEBUG_UTIL)
|
||||
|
||||
/* set usrinfo, like login(1) does */
|
||||
len = easprintf(&info, "NAME=%s%cLOGIN=%s%cLOGNAME=%s%cTTY=%s%c",
|
||||
len = sudo_easprintf(&info, "NAME=%s%cLOGIN=%s%cLOGNAME=%s%cTTY=%s%c",
|
||||
user, '\0', user, '\0', user, '\0', tty ? tty : "", '\0');
|
||||
(void)usrinfo(SETUINFO, info, len);
|
||||
efree(info);
|
||||
|
@@ -52,13 +52,13 @@
|
||||
#include "gettext.h" /* must be included before missing.h */
|
||||
|
||||
#include "missing.h"
|
||||
#include "alloc.h"
|
||||
#include "sudo_alloc.h"
|
||||
#include "fatal.h"
|
||||
|
||||
/*
|
||||
* If there is no SIZE_MAX or SIZE_T_MAX we have to assume that size_t
|
||||
* could be signed (as it is on SunOS 4.x). This just means that
|
||||
* emallocarray() and ereallocarray() cannot allocate huge amounts on such a
|
||||
* sudo_emallocarray() and sudo_ereallocarray() cannot allocate huge amounts on such a
|
||||
* platform but that is OK since sudo doesn't need to do so anyway.
|
||||
*/
|
||||
#ifndef SIZE_MAX
|
||||
@@ -70,16 +70,16 @@
|
||||
#endif /* SIZE_MAX */
|
||||
|
||||
/*
|
||||
* emalloc() calls the system malloc(3) and exits with an error if
|
||||
* sudo_emalloc() calls the system malloc(3) and exits with an error if
|
||||
* malloc(3) fails.
|
||||
*/
|
||||
void *
|
||||
emalloc(size_t size)
|
||||
sudo_emalloc(size_t size)
|
||||
{
|
||||
void *ptr;
|
||||
|
||||
if (size == 0)
|
||||
sudo_fatalx_nodebug(_("internal error, tried to emalloc(0)"));
|
||||
sudo_fatalx_nodebug(_("internal error, tried allocate zero bytes"));
|
||||
|
||||
if ((ptr = malloc(size)) == NULL)
|
||||
sudo_fatal_nodebug(NULL);
|
||||
@@ -87,18 +87,18 @@ emalloc(size_t size)
|
||||
}
|
||||
|
||||
/*
|
||||
* emallocarray() allocates nmemb * size bytes and exits with an error
|
||||
* sudo_emallocarray() allocates nmemb * size bytes and exits with an error
|
||||
* if overflow would occur or if the system malloc(3) fails.
|
||||
*/
|
||||
void *
|
||||
emallocarray(size_t nmemb, size_t size)
|
||||
sudo_emallocarray(size_t nmemb, size_t size)
|
||||
{
|
||||
void *ptr;
|
||||
|
||||
if (nmemb == 0 || size == 0)
|
||||
sudo_fatalx_nodebug(_("internal error, tried to emallocarray(0)"));
|
||||
sudo_fatalx_nodebug(_("internal error, tried allocate zero bytes"));
|
||||
if (nmemb > SIZE_MAX / size)
|
||||
sudo_fatalx_nodebug(_("internal error, %s overflow"), "emallocarray");
|
||||
sudo_fatalx_nodebug(_("internal error, %s overflow"), "sudo_emallocarray");
|
||||
|
||||
size *= nmemb;
|
||||
if ((ptr = malloc(size)) == NULL)
|
||||
@@ -107,20 +107,20 @@ emallocarray(size_t nmemb, size_t size)
|
||||
}
|
||||
|
||||
/*
|
||||
* ecalloc() allocates nmemb * size bytes and exits with an error
|
||||
* sudo_ecalloc() allocates nmemb * size bytes and exits with an error
|
||||
* if overflow would occur or if the system malloc(3) fails.
|
||||
* On success, the allocated space is zero-filled.
|
||||
*/
|
||||
void *
|
||||
ecalloc(size_t nmemb, size_t size)
|
||||
sudo_ecalloc(size_t nmemb, size_t size)
|
||||
{
|
||||
void *ptr;
|
||||
|
||||
if (nmemb == 0 || size == 0)
|
||||
sudo_fatalx_nodebug(_("internal error, tried to ecalloc(0)"));
|
||||
sudo_fatalx_nodebug(_("internal error, tried allocate zero bytes"));
|
||||
if (nmemb != 1) {
|
||||
if (nmemb > SIZE_MAX / size)
|
||||
sudo_fatalx_nodebug(_("internal error, %s overflow"), "ecalloc");
|
||||
sudo_fatalx_nodebug(_("internal error, %s overflow"), "sudo_ecalloc");
|
||||
size *= nmemb;
|
||||
}
|
||||
if ((ptr = malloc(size)) == NULL)
|
||||
@@ -130,16 +130,16 @@ ecalloc(size_t nmemb, size_t size)
|
||||
}
|
||||
|
||||
/*
|
||||
* erealloc() calls the system realloc(3) and exits with an error if
|
||||
* realloc(3) fails. You can call erealloc() with a NULL pointer even
|
||||
* sudo_erealloc() calls the system realloc(3) and exits with an error if
|
||||
* realloc(3) fails. You can call sudo_erealloc() with a NULL pointer even
|
||||
* if the system realloc(3) does not support this.
|
||||
*/
|
||||
void *
|
||||
erealloc(void *ptr, size_t size)
|
||||
sudo_erealloc(void *ptr, size_t size)
|
||||
{
|
||||
|
||||
if (size == 0)
|
||||
sudo_fatalx_nodebug(_("internal error, tried to erealloc(0)"));
|
||||
sudo_fatalx_nodebug(_("internal error, tried allocate zero bytes"));
|
||||
|
||||
ptr = ptr ? realloc(ptr, size) : malloc(size);
|
||||
if (ptr == NULL)
|
||||
@@ -148,19 +148,19 @@ erealloc(void *ptr, size_t size)
|
||||
}
|
||||
|
||||
/*
|
||||
* ereallocarray() realloc(3)s nmemb * size bytes and exits with an error
|
||||
* if overflow would occur or if the system malloc(3)/realloc(3) fails.
|
||||
* You can call erealloc() with a NULL pointer even if the system realloc(3)
|
||||
* does not support this.
|
||||
* sudo_ereallocarray() sudo_realloc(3)s nmemb * size bytes and exits with an
|
||||
* error if overflow would occur or if the system malloc(3)/realloc(3) fails.
|
||||
* You can call sudo_ereallocarray() with a NULL pointer even if the system
|
||||
* realloc(3) does not support this.
|
||||
*/
|
||||
void *
|
||||
ereallocarray(void *ptr, size_t nmemb, size_t size)
|
||||
sudo_ereallocarray(void *ptr, size_t nmemb, size_t size)
|
||||
{
|
||||
|
||||
if (nmemb == 0 || size == 0)
|
||||
sudo_fatalx_nodebug(_("internal error, tried to ereallocarray(0)"));
|
||||
sudo_fatalx_nodebug(_("internal error, tried allocate zero bytes"));
|
||||
if (nmemb > SIZE_MAX / size)
|
||||
sudo_fatalx_nodebug(_("internal error, %s overflow"), "ereallocarray");
|
||||
sudo_fatalx_nodebug(_("internal error, %s overflow"), "sudo_ereallocarray");
|
||||
|
||||
size *= nmemb;
|
||||
ptr = ptr ? realloc(ptr, size) : malloc(size);
|
||||
@@ -170,20 +170,20 @@ ereallocarray(void *ptr, size_t nmemb, size_t size)
|
||||
}
|
||||
|
||||
/*
|
||||
* erecalloc() realloc(3)s nmemb * msize bytes and exits with an error
|
||||
* sudo_ersudo_ecalloc() realloc(3)s nmemb * msize bytes and exits with an error
|
||||
* if overflow would occur or if the system malloc(3)/realloc(3) fails.
|
||||
* On success, the new space is zero-filled. You can call erealloc()
|
||||
* On success, the new space is zero-filled. You can call sudo_erealloc()
|
||||
* with a NULL pointer even if the system realloc(3) does not support this.
|
||||
*/
|
||||
void *
|
||||
erecalloc(void *ptr, size_t onmemb, size_t nmemb, size_t msize)
|
||||
ersudo_ecalloc(void *ptr, size_t onmemb, size_t nmemb, size_t msize)
|
||||
{
|
||||
size_t size;
|
||||
|
||||
if (nmemb == 0 || msize == 0)
|
||||
sudo_fatalx_nodebug(_("internal error, tried to erecalloc(0)"));
|
||||
sudo_fatalx_nodebug(_("internal error, tried allocate zero bytes"));
|
||||
if (nmemb > SIZE_MAX / msize)
|
||||
sudo_fatalx_nodebug(_("internal error, %s overflow"), "erecalloc");
|
||||
sudo_fatalx_nodebug(_("internal error, %s overflow"), "ersudo_ecalloc");
|
||||
|
||||
size = nmemb * msize;
|
||||
ptr = ptr ? realloc(ptr, size) : malloc(size);
|
||||
@@ -197,18 +197,18 @@ erecalloc(void *ptr, size_t onmemb, size_t nmemb, size_t msize)
|
||||
}
|
||||
|
||||
/*
|
||||
* estrdup() is like strdup(3) except that it exits with an error if
|
||||
* malloc(3) fails. NOTE: unlike strdup(3), estrdup(NULL) is legal.
|
||||
* sudo_estrdup() is like strdup(3) except that it exits with an error if
|
||||
* malloc(3) fails. NOTE: unlike strdup(3), sudo_estrdup(NULL) is legal.
|
||||
*/
|
||||
char *
|
||||
estrdup(const char *src)
|
||||
sudo_estrdup(const char *src)
|
||||
{
|
||||
char *dst = NULL;
|
||||
size_t len;
|
||||
|
||||
if (src != NULL) {
|
||||
len = strlen(src);
|
||||
dst = (char *) emalloc(len + 1);
|
||||
dst = (char *) sudo_emalloc(len + 1);
|
||||
(void) memcpy(dst, src, len);
|
||||
dst[len] = '\0';
|
||||
}
|
||||
@@ -216,11 +216,11 @@ estrdup(const char *src)
|
||||
}
|
||||
|
||||
/*
|
||||
* estrdup() is like strndup(3) except that it exits with an error if
|
||||
* malloc(3) fails. NOTE: unlike strdup(3), estrdup(NULL) is legal.
|
||||
* sudo_estrndup() is like strndup(3) except that it exits with an error if
|
||||
* malloc(3) fails. NOTE: unlike strdup(3), sudo_estrdup(NULL) is legal.
|
||||
*/
|
||||
char *
|
||||
estrndup(const char *src, size_t maxlen)
|
||||
sudo_estrndup(const char *src, size_t maxlen)
|
||||
{
|
||||
char *dst = NULL;
|
||||
size_t len = 0;
|
||||
@@ -230,7 +230,7 @@ estrndup(const char *src, size_t maxlen)
|
||||
len++;
|
||||
maxlen--;
|
||||
}
|
||||
dst = (char *) emalloc(len + 1);
|
||||
dst = (char *) sudo_emalloc(len + 1);
|
||||
(void) memcpy(dst, src, len);
|
||||
dst[len] = '\0';
|
||||
}
|
||||
@@ -238,11 +238,11 @@ estrndup(const char *src, size_t maxlen)
|
||||
}
|
||||
|
||||
/*
|
||||
* easprintf() calls vasprintf() and exits with an error if vasprintf()
|
||||
* sudo_easprintf() calls vasprintf() and exits with an error if vasprintf()
|
||||
* returns -1 (out of memory).
|
||||
*/
|
||||
int
|
||||
easprintf(char **ret, const char *fmt, ...)
|
||||
sudo_easprintf(char **ret, const char *fmt, ...)
|
||||
{
|
||||
int len;
|
||||
va_list ap;
|
||||
@@ -257,11 +257,11 @@ easprintf(char **ret, const char *fmt, ...)
|
||||
}
|
||||
|
||||
/*
|
||||
* evasprintf() calls vasprintf() and exits with an error if vasprintf()
|
||||
* sudo_evasprintf() calls vasprintf() and exits with an error if vasprintf()
|
||||
* returns -1 (out of memory).
|
||||
*/
|
||||
int
|
||||
evasprintf(char **ret, const char *format, va_list args)
|
||||
sudo_evasprintf(char **ret, const char *format, va_list args)
|
||||
{
|
||||
int len;
|
||||
|
||||
|
@@ -44,7 +44,7 @@
|
||||
#include <errno.h>
|
||||
|
||||
#include "missing.h"
|
||||
#include "alloc.h"
|
||||
#include "sudo_alloc.h"
|
||||
#include "fatal.h"
|
||||
#include "sudo_debug.h"
|
||||
#include "sudo_event.h"
|
||||
@@ -58,7 +58,7 @@ sudo_ev_base_alloc(void)
|
||||
struct sudo_event_base *base;
|
||||
debug_decl(sudo_ev_base_alloc, SUDO_DEBUG_EVENT)
|
||||
|
||||
base = ecalloc(1, sizeof(*base));
|
||||
base = sudo_ecalloc(1, sizeof(*base));
|
||||
TAILQ_INIT(&base->events);
|
||||
TAILQ_INIT(&base->timeouts);
|
||||
if (sudo_ev_base_alloc_impl(base) != 0) {
|
||||
@@ -93,7 +93,7 @@ sudo_ev_alloc(int fd, short events, sudo_ev_callback_t callback, void *closure)
|
||||
|
||||
/* XXX - sanity check events value */
|
||||
|
||||
ev = ecalloc(1, sizeof(*ev));
|
||||
ev = sudo_ecalloc(1, sizeof(*ev));
|
||||
ev->fd = fd;
|
||||
ev->events = events;
|
||||
ev->pfd_idx = -1;
|
||||
|
@@ -45,7 +45,7 @@
|
||||
#include <poll.h>
|
||||
|
||||
#include "missing.h"
|
||||
#include "alloc.h"
|
||||
#include "sudo_alloc.h"
|
||||
#include "fatal.h"
|
||||
#include "sudo_debug.h"
|
||||
#include "sudo_event.h"
|
||||
@@ -60,7 +60,7 @@ sudo_ev_base_alloc_impl(struct sudo_event_base *base)
|
||||
|
||||
base->pfd_high = -1;
|
||||
base->pfd_max = 32;
|
||||
base->pfds = ereallocarray(NULL, base->pfd_max, sizeof(struct pollfd));
|
||||
base->pfds = sudo_ereallocarray(NULL, base->pfd_max, sizeof(struct pollfd));
|
||||
for (i = 0; i < base->pfd_max; i++) {
|
||||
base->pfds[i].fd = -1;
|
||||
}
|
||||
@@ -87,7 +87,7 @@ sudo_ev_add_impl(struct sudo_event_base *base, struct sudo_event *ev)
|
||||
int i;
|
||||
base->pfd_max <<= 1;
|
||||
base->pfds =
|
||||
ereallocarray(base->pfds, base->pfd_max, sizeof(struct pollfd));
|
||||
sudo_ereallocarray(base->pfds, base->pfd_max, sizeof(struct pollfd));
|
||||
for (i = base->pfd_free; i < base->pfd_max; i++) {
|
||||
base->pfds[i].fd = -1;
|
||||
}
|
||||
|
@@ -50,7 +50,7 @@
|
||||
#include <errno.h>
|
||||
|
||||
#include "missing.h"
|
||||
#include "alloc.h"
|
||||
#include "sudo_alloc.h"
|
||||
#include "fatal.h"
|
||||
#include "sudo_debug.h"
|
||||
#include "sudo_event.h"
|
||||
@@ -64,10 +64,10 @@ sudo_ev_base_alloc_impl(struct sudo_event_base *base)
|
||||
debug_decl(sudo_ev_base_alloc_impl, SUDO_DEBUG_EVENT)
|
||||
|
||||
base->maxfd = NFDBITS - 1;
|
||||
base->readfds_in = ecalloc(1, sizeof(fd_mask));
|
||||
base->writefds_in = ecalloc(1, sizeof(fd_mask));
|
||||
base->readfds_out = ecalloc(1, sizeof(fd_mask));
|
||||
base->writefds_out = ecalloc(1, sizeof(fd_mask));
|
||||
base->readfds_in = sudo_ecalloc(1, sizeof(fd_mask));
|
||||
base->writefds_in = sudo_ecalloc(1, sizeof(fd_mask));
|
||||
base->readfds_out = sudo_ecalloc(1, sizeof(fd_mask));
|
||||
base->writefds_out = sudo_ecalloc(1, sizeof(fd_mask));
|
||||
|
||||
debug_return_int(0);
|
||||
}
|
||||
@@ -92,10 +92,10 @@ sudo_ev_add_impl(struct sudo_event_base *base, struct sudo_event *ev)
|
||||
if (ev->fd > base->maxfd) {
|
||||
const int o = (base->maxfd + 1) / NFDBITS;
|
||||
const int n = howmany(ev->fd + 1, NFDBITS);
|
||||
base->readfds_in = erecalloc(base->readfds_in, o, n, sizeof(fd_mask));
|
||||
base->writefds_in = erecalloc(base->writefds_in, o, n, sizeof(fd_mask));
|
||||
base->readfds_out = erecalloc(base->readfds_out, o, n, sizeof(fd_mask));
|
||||
base->writefds_out = erecalloc(base->writefds_out, o, n, sizeof(fd_mask));
|
||||
base->readfds_in = ersudo_ecalloc(base->readfds_in, o, n, sizeof(fd_mask));
|
||||
base->writefds_in = ersudo_ecalloc(base->writefds_in, o, n, sizeof(fd_mask));
|
||||
base->readfds_out = ersudo_ecalloc(base->readfds_out, o, n, sizeof(fd_mask));
|
||||
base->writefds_out = ersudo_ecalloc(base->writefds_out, o, n, sizeof(fd_mask));
|
||||
base->maxfd = (n * NFDBITS) - 1;
|
||||
}
|
||||
|
||||
|
@@ -32,7 +32,7 @@
|
||||
#include "gettext.h" /* must be included before missing.h */
|
||||
|
||||
#include "missing.h"
|
||||
#include "alloc.h"
|
||||
#include "sudo_alloc.h"
|
||||
#include "fatal.h"
|
||||
#include "queue.h"
|
||||
#include "sudo_plugin.h"
|
||||
@@ -137,7 +137,7 @@ _warning(int use_errno, const char *fmt, va_list ap)
|
||||
int serrno = errno;
|
||||
char *str;
|
||||
|
||||
evasprintf(&str, fmt, ap);
|
||||
sudo_evasprintf(&str, fmt, ap);
|
||||
if (use_errno) {
|
||||
if (fmt != NULL) {
|
||||
sudo_printf(SUDO_CONV_ERROR_MSG,
|
||||
|
@@ -33,7 +33,7 @@
|
||||
#include "gettext.h" /* must be included before missing.h */
|
||||
|
||||
#include "missing.h"
|
||||
#include "alloc.h"
|
||||
#include "sudo_alloc.h"
|
||||
#include "fatal.h"
|
||||
#include "sudo_debug.h"
|
||||
#include "sudo_util.h"
|
||||
@@ -67,7 +67,7 @@ sudo_parse_gids(const char *gidstr, const gid_t *basegid, GETGROUPS_T **gidsp)
|
||||
ngids++;
|
||||
/* Allocate and fill in array. */
|
||||
if (ngids != 0) {
|
||||
gids = emallocarray(ngids, sizeof(GETGROUPS_T));
|
||||
gids = sudo_emallocarray(ngids, sizeof(GETGROUPS_T));
|
||||
ngids = 0;
|
||||
if (basegid != NULL)
|
||||
gids[ngids++] = *basegid;
|
||||
|
@@ -43,7 +43,7 @@
|
||||
#include <ctype.h>
|
||||
|
||||
#include "missing.h"
|
||||
#include "alloc.h"
|
||||
#include "sudo_alloc.h"
|
||||
#include "fatal.h"
|
||||
#include "sudo_lbuf.h"
|
||||
#include "sudo_debug.h"
|
||||
@@ -83,7 +83,7 @@ sudo_lbuf_expand(struct sudo_lbuf *lbuf, int extra)
|
||||
do {
|
||||
lbuf->size += 256;
|
||||
} while (lbuf->len + extra + 1 >= lbuf->size);
|
||||
lbuf->buf = erealloc(lbuf->buf, lbuf->size);
|
||||
lbuf->buf = sudo_erealloc(lbuf->buf, lbuf->size);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -51,7 +51,7 @@
|
||||
#define SUDO_ERROR_WRAP 0
|
||||
|
||||
#include "missing.h"
|
||||
#include "alloc.h"
|
||||
#include "sudo_alloc.h"
|
||||
#include "fatal.h"
|
||||
#include "pathnames.h"
|
||||
#include "sudo_plugin.h"
|
||||
@@ -234,8 +234,8 @@ set_debug(const char *entry, const char *conf_file)
|
||||
debug_flags++;
|
||||
|
||||
/* Set debug file and parse the flags (init debug as soon as possible). */
|
||||
debug_file = estrndup(entry, filelen);
|
||||
debug_flags = estrdup(debug_flags);
|
||||
debug_file = sudo_estrndup(entry, filelen);
|
||||
debug_flags = sudo_estrdup(debug_flags);
|
||||
sudo_debug_init(debug_file, debug_flags);
|
||||
efree(debug_file);
|
||||
|
||||
@@ -260,7 +260,7 @@ set_path(const char *entry, const char *conf_file)
|
||||
for (cur = sudo_conf_data.paths; cur->pname != NULL; cur++) {
|
||||
if (strncasecmp(name, cur->pname, cur->pnamelen) == 0 &&
|
||||
isblank((unsigned char)name[cur->pnamelen])) {
|
||||
cur->pval = estrdup(path);
|
||||
cur->pval = sudo_estrdup(path);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -293,24 +293,24 @@ set_plugin(const char *entry, const char *conf_file)
|
||||
while (isblank((unsigned char)*ep))
|
||||
ep++;
|
||||
}
|
||||
options = emallocarray(nopts + 1, sizeof(*options));
|
||||
options = sudo_emallocarray(nopts + 1, sizeof(*options));
|
||||
/* Fill in options array, there is at least one element. */
|
||||
for (nopts = 0; (ep = strpbrk(cp, " \t")) != NULL; ) {
|
||||
options[nopts++] = estrndup(cp, (size_t)(ep - cp));
|
||||
options[nopts++] = sudo_estrndup(cp, (size_t)(ep - cp));
|
||||
while (isblank((unsigned char)*ep))
|
||||
ep++;
|
||||
cp = ep;
|
||||
}
|
||||
options[nopts++] = estrdup(cp);
|
||||
options[nopts++] = sudo_estrdup(cp);
|
||||
options[nopts] = NULL;
|
||||
} else {
|
||||
/* No extra options. */
|
||||
pathlen = strlen(path);
|
||||
}
|
||||
|
||||
info = ecalloc(1, sizeof(*info));
|
||||
info->symbol_name = estrndup(name, namelen);
|
||||
info->path = estrndup(path, pathlen);
|
||||
info = sudo_ecalloc(1, sizeof(*info));
|
||||
info->symbol_name = sudo_estrndup(name, namelen);
|
||||
info->path = sudo_estrndup(path, pathlen);
|
||||
info->options = options;
|
||||
info->lineno = conf_lineno;
|
||||
TAILQ_INSERT_TAIL(&sudo_conf_data.plugins, info, entries);
|
||||
@@ -390,7 +390,7 @@ sudo_conf_read(const char *conf_file)
|
||||
struct stat sb;
|
||||
FILE *fp;
|
||||
char *cp, *line = NULL;
|
||||
char *prev_locale = estrdup(setlocale(LC_ALL, NULL));
|
||||
char *prev_locale = sudo_estrdup(setlocale(LC_ALL, NULL));
|
||||
size_t linesize = 0;
|
||||
|
||||
/* Parse sudo.conf in the "C" locale. */
|
||||
|
@@ -51,7 +51,7 @@
|
||||
#include "gettext.h" /* must be included before missing.h */
|
||||
|
||||
#include "missing.h"
|
||||
#include "alloc.h"
|
||||
#include "sudo_alloc.h"
|
||||
#include "fatal.h"
|
||||
#include "sudo_plugin.h"
|
||||
#include "sudo_debug.h"
|
||||
|
@@ -26,20 +26,6 @@ atobool
|
||||
atoid
|
||||
atomode
|
||||
closefrom_fallback
|
||||
easprintf
|
||||
ecalloc
|
||||
emalloc
|
||||
emallocarray
|
||||
erealloc
|
||||
ereallocarray
|
||||
erecalloc
|
||||
estrdup
|
||||
estrndup
|
||||
evasprintf
|
||||
sudo_fatal_callback_deregister
|
||||
sudo_fatal_callback_register
|
||||
sudo_fatal_nodebug
|
||||
sudo_fatalx_nodebug
|
||||
getprogname
|
||||
initprogname
|
||||
isblank
|
||||
@@ -81,6 +67,15 @@ sudo_dso_load
|
||||
sudo_dso_preload_table
|
||||
sudo_dso_strerror
|
||||
sudo_dso_unload
|
||||
sudo_easprintf
|
||||
sudo_ecalloc
|
||||
sudo_emalloc
|
||||
sudo_emallocarray
|
||||
sudo_erealloc
|
||||
sudo_ereallocarray
|
||||
sudo_erecalloc
|
||||
sudo_estrdup
|
||||
sudo_estrndup
|
||||
sudo_ev_add
|
||||
sudo_ev_alloc
|
||||
sudo_ev_base_alloc
|
||||
@@ -94,6 +89,11 @@ sudo_ev_loop
|
||||
sudo_ev_loopbreak
|
||||
sudo_ev_loopcontinue
|
||||
sudo_ev_loopexit
|
||||
sudo_evasprintf
|
||||
sudo_fatal_callback_deregister
|
||||
sudo_fatal_callback_register
|
||||
sudo_fatal_nodebug
|
||||
sudo_fatalx_nodebug
|
||||
sudo_fnmatch
|
||||
sudo_freeaddrinfo
|
||||
sudo_futimes
|
||||
@@ -141,9 +141,9 @@ sudo_term_raw
|
||||
sudo_term_restore
|
||||
sudo_utimes
|
||||
sudo_vasprintf
|
||||
sudo_vsnprintf
|
||||
sudo_vfatal_nodebug
|
||||
sudo_vfatalx_nodebug
|
||||
sudo_vsnprintf
|
||||
sudo_vwarn_nodebug
|
||||
sudo_vwarnx_nodebug
|
||||
sudo_warn_gettext
|
||||
|
Reference in New Issue
Block a user