Changeset 250 in openpam for trunk


Ignore:
Timestamp:
Jun 9, 2003, 12:47:28 AM (16 years ago)
Author:
Dag-Erling Smørgrav
Message:

Paranoia: clear buffers before returning.

Submitted by: Dmitry V. Levin <ldv@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/openpam_ttyconv.c

    r245 r250  
    3232 * SUCH DAMAGE.
    3333 *
    34  * $P4: //depot/projects/openpam/lib/openpam_ttyconv.c#20 $
     34 * $P4: //depot/projects/openpam/lib/openpam_ttyconv.c#21 $
    3535 */
    3636
     
    6969        unsigned int saved_alarm;
    7070        size_t len;
     71        char *retval;
    7172
    7273        sigemptyset(&sigset);
     
    9091        sigprocmask(SIG_SETMASK, &saved_sigset, NULL);
    9192        alarm(saved_alarm);
    92         if (timed_out || ferror(stdin) || feof(stdin))
     93        if (timed_out || ferror(stdin) || feof(stdin)) {
     94                memset(buf, 0, sizeof(buf));
    9395                return (NULL);
     96        }
    9497        /* trim trailing whitespace */
    9598        for (len = strlen(buf); len > 0; --len)
     
    97100                        break;
    98101        buf[len] = '\0';
    99         return (strdup(buf));
     102        retval = strdup(buf);
     103        memset(buf, 0, sizeof(buf));
     104        return (retval);
    100105}
    101106
     
    180185 fail:
    181186        while (i)
    182                 FREE(resp[--i]);
     187                if (resp[--i]->resp) {
     188                        memset(resp[i]->resp, 0, strlen(resp[i]->resp));
     189                        FREE(resp[i]->resp);
     190                }
    183191        FREE(*resp);
    184192        RETURNC(PAM_CONV_ERR);
Note: See TracChangeset for help on using the changeset viewer.