1
0
mirror of https://github.com/moparisthebest/curl synced 2025-02-28 09:21:50 -05:00

parsedate.c: check sscanf result before passing it to strlen

This commit is contained in:
Marc Hoersken 2014-04-19 15:47:07 +02:00
parent 662fc62517
commit 9146f37973

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -353,9 +353,11 @@ static int parsedate(const char *date, time_t *output)
/* a name coming up */ /* a name coming up */
char buf[32]=""; char buf[32]="";
size_t len; size_t len;
sscanf(date, "%31[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz]", if(sscanf(date, "%31[ABCDEFGHIJKLMNOPQRSTUVWXYZ"
buf); "abcdefghijklmnopqrstuvwxyz]", buf))
len = strlen(buf); len = strlen(buf);
else
len = 0;
if(wdaynum == -1) { if(wdaynum == -1) {
wdaynum = checkday(buf, len); wdaynum = checkday(buf, len);