#include "shadowlog_internal.h"
#include "sssd.h"
#include "string/memset/memzero.h"
+#include "string/sprintf/aprintf.h"
#include "string/sprintf/snprintf.h"
#include "string/strcmp/streq.h"
#include "string/strcmp/strprefix.h"
return 1;
}
- if (asprintf(&file, "%s.%ju", db->filename, (uintmax_t) getpid()) == -1)
+ file = aprintf("%s.%ju", db->filename, (uintmax_t) getpid());
+ if (file == NULL)
goto cleanup_ENOMEM;
- if (asprintf(&lock, "%s.lock", db->filename) == -1)
+
+ lock = aprintf("%s.lock", db->filename);
+ if (lock == NULL)
goto cleanup_ENOMEM;
if (do_lock_file (file, lock, log) != 0) {
#include <attr/libattr.h>
#endif /* WITH_ATTR */
#include "shadowlog.h"
+#include "string/sprintf/aprintf.h"
#include "string/sprintf/xasprintf.h"
#include "string/strcmp/streq.h"
#include "string/strcmp/strprefix.h"
continue;
}
- if (asprintf(&src_name, "%s/%s", src->full_path, ent->d_name) == -1)
- {
+ src_name = aprintf("%s/%s", src->full_path, ent->d_name);
+ if (src_name == NULL) {
err = -1;
continue;
}
- if (asprintf(&dst_name, "%s/%s", dst->full_path, ent->d_name) == -1)
- {
+ dst_name = aprintf("%s/%s", dst->full_path, ent->d_name);
+ if (dst_name == NULL) {
err = -1;
goto skip;
}
#include "getdef.h"
#include "groupio.h"
#include "prototypes.h"
+#include "string/sprintf/aprintf.h"
#include "string/strcmp/streq.h"
}
/* Concatenate the 2 lines */
- if (asprintf(&new_line, "%s\n%s", gr1->line, gr2->line) == -1)
+ new_line = aprintf("%s\n%s", gr1->line, gr2->line);
+ if (new_line == NULL)
return NULL;
/* Concatenate the 2 list of members */
#include "run_part.h"
#include "shadowlog_internal.h"
+#include "string/sprintf/aprintf.h"
static int run_part(char *script_path, const char *name, const char *action)
char *s;
struct stat sb;
- if (asprintf(&s, "%s/%s", directory, namelist[n]->d_name) == -1) {
- fprintf(shadow_logfd, "asprintf: %s\n", strerror(errno));
+ s = aprintf("%s/%s", directory, namelist[n]->d_name);
+ if (s == NULL) {
+ fprintf(shadow_logfd, "aprintf: %s\n", strerror(errno));
for (; n<scanlist; n++) {
free(namelist[n]);
}
#include "tcbfuncs.h"
#include "shadowio.h"
#include "shadowlog_internal.h"
+#include "string/sprintf/aprintf.h"
#include "string/strcmp/streq.h"
char *ret;
if (!getdef_bool ("TCB_SYMLINKS") || uid < SHADOWTCB_HASH_BY) {
- if (asprintf (&ret, "%s", name) == -1) {
+ ret = aprintf("%s", name);
+ if (ret == NULL) {
OUT_OF_MEMORY;
return NULL;
}
} else if (uid < SHADOWTCB_HASH_BY * SHADOWTCB_HASH_BY) {
- if (asprintf (&ret, ":%dK/%s",
- uid / SHADOWTCB_HASH_BY, name) == -1) {
+ ret = aprintf(":%dK/%s", uid / SHADOWTCB_HASH_BY, name);
+ if (ret == NULL) {
OUT_OF_MEMORY;
return NULL;
}
} else {
- if (asprintf (&ret, ":%dM/:%dK/%s",
+ ret = aprintf(":%dM/:%dK/%s",
uid / (SHADOWTCB_HASH_BY * SHADOWTCB_HASH_BY),
(uid % (SHADOWTCB_HASH_BY * SHADOWTCB_HASH_BY)) / SHADOWTCB_HASH_BY,
- name) == -1) {
+ name);
+ if (ret == NULL) {
OUT_OF_MEMORY;
return NULL;
}
struct stat st;
char link[8192];
- if (asprintf (&path, TCB_DIR "/%s", name) == -1) {
+ path = aprintf(TCB_DIR "/%s", name);
+ if (path == NULL) {
OUT_OF_MEMORY;
return NULL;
}
if (NULL == rel) {
return NULL;
}
- if (asprintf (&ret, TCB_DIR "/%s", rel) == -1) {
+ ret = aprintf(TCB_DIR "/%s", rel);
+ if (ret == NULL) {
OUT_OF_MEMORY;
free (rel);
return NULL;
if (NULL == rel) {
return NULL;
}
- if (asprintf (&ret, TCB_DIR "/%s", rel) == -1) {
+ ret = aprintf(TCB_DIR "/%s", rel);
+ if (ret == NULL) {
OUT_OF_MEMORY;
free (rel);
return NULL;
}
while ((ind = strchr (ptr, '/'))) {
stpcpy(ind, "");
- if (asprintf (&dir, TCB_DIR "/%s", path) == -1) {
+ dir = aprintf(TCB_DIR "/%s", path);
+ if (dir == NULL) {
OUT_OF_MEMORY;
return SHADOWTCB_FAILURE;
}
int i;
for (i = 0; i < 3; i++) {
- if (asprintf (&tmp, TCB_FMT "%s", user, suffs[i]) == -1) {
+ tmp = aprintf(TCB_FMT "%s", user, suffs[i]);
+ if (tmp == NULL) {
OUT_OF_MEMORY;
return SHADOWTCB_FAILURE;
}
shadowtcb_status ret = SHADOWTCB_SUCCESS;
while ((ind = strrchr (path, '/'))) {
stpcpy(ind, "");
- if (asprintf (&dir, TCB_DIR "/%s", path) == -1) {
+ dir = aprintf(TCB_DIR "/%s", path);
+ if (dir == NULL) {
OUT_OF_MEMORY;
return SHADOWTCB_FAILURE;
}
if (NULL == stored_tcb_user) {
return SHADOWTCB_FAILURE;
}
- if (asprintf (&olddir, TCB_DIR "/%s", stored_tcb_user) == -1) {
+ olddir = aprintf(TCB_DIR "/%s", stored_tcb_user);
+ if (olddir == NULL) {
goto out_free_nomem;
}
if (stat (olddir, &oldmode) != 0) {
shadow_progname, olddir, strerror (errno));
goto out_free;
}
- if (asprintf (&newdir, TCB_DIR "/%s", user_newname) == -1) {
+ newdir = aprintf(TCB_DIR "/%s", user_newname);
+ if (newdir == NULL) {
goto out_free_nomem;
}
real_new_dir_rel = shadowtcb_path_rel (user_newname, the_newid);
OUT_OF_MEMORY;
return SHADOWTCB_FAILURE;
}
- if (asprintf (&buf, TCB_FMT, name) == -1) {
+ buf = aprintf(TCB_FMT, name);
+ if (buf == NULL) {
OUT_OF_MEMORY;
return SHADOWTCB_FAILURE;
}
}
free (path);
free (rel);
- if (asprintf (&path, TCB_DIR "/%s", name) == -1) {
+ path = aprintf(TCB_DIR "/%s", name);
+ if (path == NULL) {
OUT_OF_MEMORY;
return SHADOWTCB_FAILURE;
}
if (-1 == user_newid) {
return SHADOWTCB_SUCCESS;
}
- if (asprintf(&tcbdir, TCB_DIR "/%s", user_newname) == -1) {
+ tcbdir = aprintf(TCB_DIR "/%s", user_newname);
+ if (tcbdir == NULL) {
OUT_OF_MEMORY;
return SHADOWTCB_FAILURE;
}
- if (asprintf(&shadow, TCB_FMT, user_newname) == -1) {
+ shadow = aprintf(TCB_FMT, user_newname);
+ if (shadow == NULL) {
OUT_OF_MEMORY;
return SHADOWTCB_FAILURE;
}
}
}
- if (asprintf(&dir, TCB_DIR "/%s", name) == -1) {
+ dir = aprintf(TCB_DIR "/%s", name);
+ if (dir == NULL) {
OUT_OF_MEMORY;
return SHADOWTCB_FAILURE;
}
- if (asprintf(&shadow, TCB_FMT, name) == -1) {
+ shadow = aprintf(TCB_FMT, name);
+ if (shadow == NULL) {
OUT_OF_MEMORY;
return SHADOWTCB_FAILURE;
}
#include "shadowlog.h"
#include "sssd.h"
#include "string/memset/memzero.h"
+#include "string/sprintf/aprintf.h"
#include "string/sprintf/snprintf.h"
#include "string/sprintf/xasprintf.h"
#include "string/strcmp/strcaseeq.h"
const char *ccp;
if (prefix[0]) {
- if (asprintf(&default_file, "%s/%s", prefix, USER_DEFAULTS_FILE) == -1)
+ default_file = aprintf("%s/%s", prefix, USER_DEFAULTS_FILE);
+ if (default_file == NULL)
return;
}
FILE *ofp;
- if (asprintf(&new_file, "%s%s%s", prefix, prefix[0]?"/":"", NEW_USER_FILE) == -1)
- {
+ new_file = aprintf("%s%s%s", prefix, prefix[0]?"/":"", NEW_USER_FILE);
+ if (new_file == NULL) {
fprintf(stderr, _("%s: cannot create new defaults file: %s\n"),
Prog, strerror(errno));
return -1;
}
if (prefix[0]) {
- if (asprintf(&default_file, "%s/%s", prefix, USER_DEFAULTS_FILE) == -1)
- {
+ default_file = aprintf("%s/%s", prefix, USER_DEFAULTS_FILE);
+ if (default_file == NULL) {
fprintf(stderr,
_("%s: cannot create new defaults file: %s\n"),
Prog, strerror(errno));
#include "subordinateio.h"
#endif /* ENABLE_SUBIDS */
#include "shadowlog.h"
+#include "string/sprintf/aprintf.h"
#include "string/sprintf/xasprintf.h"
#include "string/strcmp/streq.h"
#include "string/strcmp/strprefix.h"
return 0;
}
- if (asprintf(&buf, TCB_DIR "/%s", user_name) == -1) {
+ buf = aprintf(TCB_DIR "/%s", user_name);
+ if (buf == NULL) {
fprintf(stderr,
_("%s: Can't allocate memory, tcb entry for %s not removed.\n"),
Prog, user_name);
#endif /* WITH_TCB */
#include "shadowlog.h"
#include "sssd.h"
+#include "string/sprintf/aprintf.h"
#include "string/sprintf/snprintf.h"
#include "string/sprintf/xasprintf.h"
#include "string/strcmp/streq.h"
if (stat (file, &st1) != 0) {
vipwexit (_("failed to stat edited file"), errno, 1);
}
- if (asprintf(&to_rename, "%s+", file) == -1)
- vipwexit (_("asprintf(3) failed"), errno, 1);
+ to_rename = aprintf("%s+", file);
+ if (to_rename == NULL)
+ vipwexit (_("aprintf() failed"), errno, 1);
if (create_backup_file (f, to_rename, &st1) != 0) {
free(to_rename);