Changeset 582 in openpam


Ignore:
Timestamp:
Apr 6, 2012, 11:23:35 PM (2 years ago)
Author:
des
Message:

Check the return value from asprintf().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bin/openpam_dump_policy/openpam_dump_policy.c

    r578 r582  
    4646 
    4747static char * 
    48 openpam_chain_name(const char *service, pam_facility_t facility) 
    49 { 
     48openpam_chain_name(const char *service, pam_facility_t fclt) 
     49{ 
     50        const char *facility = pam_facility_name[fclt]; 
    5051        char *name; 
    5152 
    52         asprintf(&name, "pam_%s_%s", service, pam_facility_name[facility]); 
     53        if (asprintf(&name, "pam_%s_%s", service, facility) == -1) 
     54                return (NULL); 
    5355        return (name); 
    5456} 
    5557 
    5658static char * 
    57 openpam_facility_index_name(pam_facility_t facility) 
    58 { 
     59openpam_facility_index_name(pam_facility_t fclt) 
     60{ 
     61        const char *facility = pam_facility_name[fclt]; 
    5962        char *name, *p; 
    6063 
    61         asprintf(&name, "PAM_%s", pam_facility_name[facility]); 
     64        if (asprintf(&name, "PAM_%s", facility) == -1) 
     65                return (NULL); 
    6266        for (p = name + 4; *p; ++p) 
    6367                *p = toupper(*p); 
Note: See TracChangeset for help on using the changeset viewer.