Do not use asprintf.
Showing
2 changed files
with
30 additions
and
12 deletions
... | @@ -44,7 +44,6 @@ | ... | @@ -44,7 +44,6 @@ |
44 | #include <mailutils/mailbox.h> | 44 | #include <mailutils/mailbox.h> |
45 | 45 | ||
46 | #include <argcv.h> | 46 | #include <argcv.h> |
47 | #include <mu_asprintf.h> | ||
48 | 47 | ||
49 | #define ARG_LOG_FACILITY 1 | 48 | #define ARG_LOG_FACILITY 1 |
50 | #define ARG_LOCK_FLAGS 2 | 49 | #define ARG_LOCK_FLAGS 2 |
... | @@ -638,15 +637,20 @@ mu_create_argcv (const char *capa[], | ... | @@ -638,15 +637,20 @@ mu_create_argcv (const char *capa[], |
638 | } | 637 | } |
639 | else | 638 | else |
640 | { | 639 | { |
641 | char* userrc = NULL; | 640 | char *userrc = NULL; |
642 | 641 | ||
643 | mu_asprintf(&userrc, "%s/mailutils", MU_USER_CONFIG_FILE); | 642 | userrc = malloc (sizeof (MU_USER_CONFIG_FILE) /* provides an extra slot |
643 | for null byte as well */ | ||
644 | + 1 /* slash */ | ||
645 | + 9 /*mailutils*/); | ||
644 | 646 | ||
645 | if (!userrc) | 647 | if (!userrc) |
646 | { | 648 | { |
647 | fprintf (stderr, "%s: not enough memory\n", progname); | 649 | fprintf (stderr, "%s: not enough memory\n", progname); |
648 | exit (1); | 650 | exit (1); |
649 | } | 651 | } |
652 | |||
653 | sprintf(userrc, "%s/mailutils", MU_USER_CONFIG_FILE); | ||
650 | read_rc (progname, userrc, capa, &x_argc, &x_argv); | 654 | read_rc (progname, userrc, capa, &x_argc, &x_argv); |
651 | 655 | ||
652 | free(userrc); | 656 | free(userrc); |
... | @@ -654,12 +658,20 @@ mu_create_argcv (const char *capa[], | ... | @@ -654,12 +658,20 @@ mu_create_argcv (const char *capa[], |
654 | 658 | ||
655 | /* Add per-user, per-program config file. */ | 659 | /* Add per-user, per-program config file. */ |
656 | { | 660 | { |
657 | char* progrc = NULL; | 661 | char *progrc = NULL; |
662 | int size; | ||
658 | 663 | ||
659 | if(rcdir) | 664 | if (rcdir) |
660 | mu_asprintf(&progrc, "%s/%src", MU_USER_CONFIG_FILE, progname); | 665 | size = sizeof (MU_USER_CONFIG_FILE) |
666 | + 1 | ||
667 | + strlen (progname) | ||
668 | + 2 /* rc */; | ||
661 | else | 669 | else |
662 | mu_asprintf(&progrc, "~/.mu.%src", progname); | 670 | size = 6 /*~/.mu.*/ |
671 | + strlen (progname) | ||
672 | + 3 /* "rc" + null terminator */; | ||
673 | |||
674 | progrc = malloc (size); | ||
663 | 675 | ||
664 | if (!progrc) | 676 | if (!progrc) |
665 | { | 677 | { |
... | @@ -667,6 +679,11 @@ mu_create_argcv (const char *capa[], | ... | @@ -667,6 +679,11 @@ mu_create_argcv (const char *capa[], |
667 | exit (1); | 679 | exit (1); |
668 | } | 680 | } |
669 | 681 | ||
682 | if (rcdir) | ||
683 | sprintf (progrc, "%s/%src", MU_USER_CONFIG_FILE, progname); | ||
684 | else | ||
685 | sprintf (progrc, "~/.mu.%src", progname); | ||
686 | |||
670 | read_rc (NULL, progrc, capa, &x_argc, &x_argv); | 687 | read_rc (NULL, progrc, capa, &x_argc, &x_argv); |
671 | free (progrc); | 688 | free (progrc); |
672 | } | 689 | } | ... | ... |
... | @@ -47,8 +47,6 @@ | ... | @@ -47,8 +47,6 @@ |
47 | #include <mailutils/parse822.h> | 47 | #include <mailutils/parse822.h> |
48 | #include <mailutils/mu_auth.h> | 48 | #include <mailutils/mu_auth.h> |
49 | 49 | ||
50 | #include "mu_asprintf.h" | ||
51 | |||
52 | /* convert a sequence of hex characters into an integer */ | 50 | /* convert a sequence of hex characters into an integer */ |
53 | 51 | ||
54 | unsigned long | 52 | unsigned long |
... | @@ -595,12 +593,15 @@ mu_get_user_email (const char *name) | ... | @@ -595,12 +593,15 @@ mu_get_user_email (const char *name) |
595 | return NULL; | 593 | return NULL; |
596 | } | 594 | } |
597 | 595 | ||
598 | mu_asprintf (&email, "%s@%s", localpart, domainpart); | ||
599 | |||
600 | free (localpart); | ||
601 | 596 | ||
597 | email = malloc (strlen (localpart) + 1 | ||
598 | + strlen (domainpart) + 1); | ||
602 | if (!email) | 599 | if (!email) |
603 | errno = ENOMEM; | 600 | errno = ENOMEM; |
601 | else | ||
602 | sprintf (email, "%s@%s", localpart, domainpart); | ||
603 | |||
604 | free (localpart); | ||
604 | 605 | ||
605 | return email; | 606 | return email; |
606 | } | 607 | } | ... | ... |
-
Please register or sign in to post a comment