Ignore:
Timestamp:
Nov 12, 2012, 4:35:55 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server 3.5: update branche to 3.5.12

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/samba-3.5.x/source3/web/swat.c

    r617 r732  
    169169
    170170                snprintf(tmp, sizeof(tmp), "%02x", token[i]);
    171                 strncat(token_str, tmp, sizeof(tmp));
     171                strlcat(token_str, tmp, sizeof(tmp));
    172172        }
    173173}
     
    193193        const char *token = cgi_variable_nonull(XSRF_TOKEN);
    194194        const char *time_str = cgi_variable_nonull(XSRF_TIME);
     195        char *p = NULL;
     196        long long xsrf_time_ll = 0;
    195197        time_t xsrf_time = 0;
    196198        time_t now = time(NULL);
    197199
    198         if (sizeof(time_t) == sizeof(int)) {
    199                 xsrf_time = atoi(time_str);
    200         } else if (sizeof(time_t) == sizeof(long)) {
    201                 xsrf_time = atol(time_str);
    202         } else if (sizeof(time_t) == sizeof(long long)) {
    203                 xsrf_time = atoll(time_str);
    204         }
     200        errno = 0;
     201        xsrf_time_ll = strtoll(time_str, &p, 10);
     202        if (errno != 0) {
     203                return false;
     204        }
     205        if (p == NULL) {
     206                return false;
     207        }
     208        if (PTR_DIFF(p, time_str) > strlen(time_str)) {
     209                return false;
     210        }
     211        if (xsrf_time_ll > _TYPE_MAXIMUM(time_t)) {
     212                return false;
     213        }
     214        if (xsrf_time_ll < _TYPE_MINIMUM(time_t)) {
     215                return false;
     216        }
     217        xsrf_time = xsrf_time_ll;
    205218
    206219        if (abs(now - xsrf_time) > XSRF_TIMEOUT) {
Note: See TracChangeset for help on using the changeset viewer.