diff options
author | Stefan Metzmacher <metze@samba.org> | 2011-08-05 19:48:38 +0200 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2011-08-06 11:55:45 +0200 |
commit | a6be0820d09b3f3eabfbb5f4356add303aa8a494 (patch) | |
tree | c89aec5d13bd679b44b557a05f6fc91eeead13aa /source3 | |
parent | 10752c5b5b039f4645412d81a751dbb926361c9e (diff) | |
download | samba-a6be0820d09b3f3eabfbb5f4356add303aa8a494.tar.gz samba-a6be0820d09b3f3eabfbb5f4356add303aa8a494.tar.bz2 samba-a6be0820d09b3f3eabfbb5f4356add303aa8a494.zip |
s3:web/swat: use strtoll() instead of atoi/atol/atoll
This is more portable, as we have a strtoll replacement
in lib/replace.
metze
Autobuild-User: Stefan Metzmacher <metze@samba.org>
Autobuild-Date: Sat Aug 6 11:55:45 CEST 2011 on sn-devel-104
Diffstat (limited to 'source3')
-rw-r--r-- | source3/web/swat.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/source3/web/swat.c b/source3/web/swat.c index 69d9fec64f..1ecaa5795d 100644 --- a/source3/web/swat.c +++ b/source3/web/swat.c @@ -199,16 +199,29 @@ bool verify_xsrf_token(const char *formname) const char *pass = cgi_user_pass(); const char *token = cgi_variable_nonull(XSRF_TOKEN); const char *time_str = cgi_variable_nonull(XSRF_TIME); + char *p = NULL; + long long xsrf_time_ll = 0; time_t xsrf_time = 0; time_t now = time(NULL); - if (sizeof(time_t) == sizeof(int)) { - xsrf_time = atoi(time_str); - } else if (sizeof(time_t) == sizeof(long)) { - xsrf_time = atol(time_str); - } else if (sizeof(time_t) == sizeof(long long)) { - xsrf_time = atoll(time_str); + errno = 0; + xsrf_time_ll = strtoll(time_str, &p, 10); + if (errno != 0) { + return false; + } + if (p == NULL) { + return false; + } + if (PTR_DIFF(p, time_str) > strlen(time_str)) { + return false; + } + if (xsrf_time_ll > _TYPE_MAXIMUM(time_t)) { + return false; + } + if (xsrf_time_ll < _TYPE_MINIMUM(time_t)) { + return false; } + xsrf_time = xsrf_time_ll; if (abs(now - xsrf_time) > XSRF_TIMEOUT) { return false; |