Changeset 233 in openpam for trunk


Ignore:
Timestamp:
May 24, 2003, 7:47:00 PM (16 years ago)
Author:
Dag-Erling Smørgrav
Message:

Two more cases of asprintf(3) replacing malloc(3) + sprintf(3).

Location:
trunk/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/openpam_set_option.c

    r232 r233  
    3232 * SUCH DAMAGE.
    3333 *
    34  * $P4: //depot/projects/openpam/lib/openpam_set_option.c#10 $
     34 * $P4: //depot/projects/openpam/lib/openpam_set_option.c#11 $
    3535 */
    3636
     
    8383                RETURNC(PAM_SUCCESS);
    8484        }
    85         if ((opt = malloc(len + strlen(value) + 2)) == NULL)
     85        if (asprintf(&opt, "%.*s=%s", (int)len, option, value) < 0)
    8686                RETURNC(PAM_BUF_ERR);
    87         sprintf(opt, "%.*s=%s", (int)len, option, value);
    8887        if (i == cur->optc) {
    8988                /* add */
  • trunk/lib/pam_setenv.c

    r232 r233  
    3232 * SUCH DAMAGE.
    3333 *
    34  * $P4: //depot/projects/openpam/lib/pam_setenv.c#9 $
     34 * $P4: //depot/projects/openpam/lib/pam_setenv.c#10 $
    3535 */
    3636
     
    7272
    7373        /* set it... */
    74         if ((env = malloc(strlen(name) + strlen(value) + 2)) == NULL)
     74        if (asprintf(&env, "%s=%s", name, value) < 0)
    7575                RETURNC(PAM_BUF_ERR);
    76         sprintf(env, "%s=%s", name, value);
    7776        r = pam_putenv(pamh, env);
    7877        FREE(env);
Note: See TracChangeset for help on using the changeset viewer.