src/: Use xasprintf() instead of its pattern

Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
Alejandro Colomar
2024-05-13 14:37:14 +02:00
committed by Serge Hallyn
parent 44ba094766
commit d9923431eb
4 changed files with 10 additions and 15 deletions

View File

@@ -21,6 +21,7 @@
#include "prototypes.h"
#include "defines.h"
#include "getdef.h"
#include "string/sprintf/xasprintf.h"
#if WITH_LIBBSD == 0
#include "freezero.h"
@@ -99,9 +100,7 @@ static /*@observer@*//*@null@*/const char *password_check (
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");

View File

@@ -22,7 +22,6 @@
#include "alloc.h"
#include "agetpass.h"
#include "alloc.h"
#include "atoi/str2i.h"
#include "defines.h"
#include "getdef.h"
@@ -34,6 +33,7 @@
#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"
@@ -532,10 +532,9 @@ static char *update_crypt_pw (char *cp)
}
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) {

View File

@@ -60,6 +60,7 @@
#include "exitcodes.h"
#include "shadowlog.h"
#include "string/sprintf/snprintf.h"
#include "string/sprintf/xasprintf.h"
#include "string/strcpy/strtcpy.h"
@@ -1201,17 +1202,14 @@ int main (int argc, char **argv)
* 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);
}

View File

@@ -412,15 +412,14 @@ usage (int status)
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') {