Commit 4ec65fa5 4ec65fa5ac0400d23bc9bf78e6f6f81be6170112 by Sergey Poznyakoff

Do not use asprintf.

1 parent 8004e37a
......@@ -44,7 +44,6 @@
#include <mailutils/mailbox.h>
#include <argcv.h>
#include <mu_asprintf.h>
#define ARG_LOG_FACILITY 1
#define ARG_LOCK_FLAGS 2
......@@ -638,15 +637,20 @@ mu_create_argcv (const char *capa[],
}
else
{
char* userrc = NULL;
char *userrc = NULL;
mu_asprintf(&userrc, "%s/mailutils", MU_USER_CONFIG_FILE);
userrc = malloc (sizeof (MU_USER_CONFIG_FILE) /* provides an extra slot
for null byte as well */
+ 1 /* slash */
+ 9 /*mailutils*/);
if (!userrc)
{
fprintf (stderr, "%s: not enough memory\n", progname);
exit (1);
}
sprintf(userrc, "%s/mailutils", MU_USER_CONFIG_FILE);
read_rc (progname, userrc, capa, &x_argc, &x_argv);
free(userrc);
......@@ -654,12 +658,20 @@ mu_create_argcv (const char *capa[],
/* Add per-user, per-program config file. */
{
char* progrc = NULL;
char *progrc = NULL;
int size;
if(rcdir)
mu_asprintf(&progrc, "%s/%src", MU_USER_CONFIG_FILE, progname);
if (rcdir)
size = sizeof (MU_USER_CONFIG_FILE)
+ 1
+ strlen (progname)
+ 2 /* rc */;
else
mu_asprintf(&progrc, "~/.mu.%src", progname);
size = 6 /*~/.mu.*/
+ strlen (progname)
+ 3 /* "rc" + null terminator */;
progrc = malloc (size);
if (!progrc)
{
......@@ -667,6 +679,11 @@ mu_create_argcv (const char *capa[],
exit (1);
}
if (rcdir)
sprintf (progrc, "%s/%src", MU_USER_CONFIG_FILE, progname);
else
sprintf (progrc, "~/.mu.%src", progname);
read_rc (NULL, progrc, capa, &x_argc, &x_argv);
free (progrc);
}
......
......@@ -47,8 +47,6 @@
#include <mailutils/parse822.h>
#include <mailutils/mu_auth.h>
#include "mu_asprintf.h"
/* convert a sequence of hex characters into an integer */
unsigned long
......@@ -595,12 +593,15 @@ mu_get_user_email (const char *name)
return NULL;
}
mu_asprintf (&email, "%s@%s", localpart, domainpart);
free (localpart);
email = malloc (strlen (localpart) + 1
+ strlen (domainpart) + 1);
if (!email)
errno = ENOMEM;
else
sprintf (email, "%s@%s", localpart, domainpart);
free (localpart);
return email;
}
......