Changeset 481 in openpam for trunk


Ignore:
Timestamp:
Nov 3, 2011, 4:09:22 PM (8 years ago)
Author:
Dag-Erling Smørgrav
Message:

The include directive expects a service name, not a filename.
While there, remember to check for trailing garbage.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/openpam_configure.c

    r478 r481  
    345345}
    346346
     347/*
     348 * Consume trailing whitespace.
     349 *
     350 * If there are no non-whitespace characters left on the line, parse_eol()
     351 * updates *line to point at the terminating NUL character and returns 0.
     352 * Otherwise, it leaves *line unmodified and returns a non-zero value.
     353 */
     354static int
     355parse_eol(char **line)
     356{
     357        char *p;
     358
     359        for (p = *line; *p && is_lws(*p); ++p)
     360                /* nothing */ ;
     361        if (*p)
     362                return ((unsigned char)*p);
     363        *line = p;
     364        return (0);
     365}
     366
    347367typedef enum { pam_conf_style, pam_d_style } openpam_style_t;
    348368
     
    404424                /* check for "include" */
    405425                if (parse_include(&line)) {
    406                         if ((len = parse_filename(&line, &str)) == 0) {
     426                        if ((len = parse_service_name(&line, &str)) == 0) {
    407427                                openpam_log(PAM_LOG_ERROR,
    408428                                    "%s(%d): missing or invalid filename",
     
    412432                        if ((name = strndup(str, len)) == NULL)
    413433                                goto syserr;
     434                        if (parse_eol(&line) != 0) {
     435                                openpam_log(PAM_LOG_ERROR,
     436                                    "%s(%d): garbage at end of line",
     437                                    filename, lineno);
     438                                goto fail;
     439                        }
    414440                        ret = openpam_load_chain(pamh, name, fclt);
    415441                        FREE(name);
     
    445471
    446472                /* get module options */
    447                 /* quick and dirty, wastes a few hundred bytes */
     473                /* XXX quick and dirty, may waste a few hundred bytes */
    448474                if ((this->optv = malloc(sizeof *opt * strlen(line))) == NULL)
    449475                        goto syserr;
Note: See TracChangeset for help on using the changeset viewer.