#include "prototypes.h"
#include "defines.h"
#include "getdef.h"
+#include "string/sprintf/xasprintf.h"
#if WITH_LIBBSD == 0
#include "freezero.h"
newmono = str_lower (xstrdup (new));
oldmono = str_lower (xstrdup (old));
- wrapped = XMALLOC(strlen(oldmono) * 2 + 1, char);
- strcpy (wrapped, oldmono);
- strcat (wrapped, oldmono);
+ xasprintf(&wrapped, "%s%s", oldmono, oldmono);
if (palindrome (oldmono, newmono)) {
msg = _("a palindrome");
#include "alloc.h"
#include "agetpass.h"
-#include "alloc.h"
#include "atoi/str2i.h"
#include "defines.h"
#include "getdef.h"
#include "pwio.h"
#include "shadowio.h"
#include "shadowlog.h"
+#include "string/sprintf/xasprintf.h"
#include "string/strcpy/strtcpy.h"
#include "time/day_to_str.h"
}
if (lflg && *cp != '!') {
- char *newpw = XMALLOC(strlen(cp) + 2, char);
+ char *newpw;
- strcpy (newpw, "!");
- strcat (newpw, cp);
+ xasprintf(&newpw, "!%s", cp);
if (!use_pam)
{
if (do_update_pwd) {
#include "exitcodes.h"
#include "shadowlog.h"
#include "string/sprintf/snprintf.h"
+#include "string/sprintf/xasprintf.h"
#include "string/strcpy/strtcpy.h"
* case they will be provided to the new user's shell as arguments.
*/
if (fakelogin) {
- char *arg0;
+ char *arg0;
cp = getdef_str ("SU_NAME");
if (NULL == cp) {
cp = Basename (shellstr);
}
- arg0 = XMALLOC(strlen(cp) + 2, char);
- arg0[0] = '-';
- strcpy (arg0 + 1, cp);
- cp = arg0;
+ xasprintf(&arg0, "-%s", cp);
} else {
cp = Basename (shellstr);
}
static char *new_pw_passwd (char *pw_pass)
{
if (Lflg && ('!' != pw_pass[0])) {
- char *buf = XMALLOC(strlen(pw_pass) + 2, char);
+ char *buf;
#ifdef WITH_AUDIT
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
"updating passwd", user_newname, user_newid, 0);
#endif
SYSLOG ((LOG_INFO, "lock user '%s' password", user_newname));
- strcpy (buf, "!");
- strcat (buf, pw_pass);
+ xasprintf(&buf, "!%s", pw_pass);
pw_pass = buf;
} else if (Uflg && pw_pass[0] == '!') {
if (pw_pass[1] == '\0') {