summaryrefslogtreecommitdiff
path: root/libavformat/http.c
diff options
context:
space:
mode:
authorLimin Wang <lance.lmwang@gmail.com>2020-04-18 12:19:31 +0800
committerLimin Wang <lance.lmwang@gmail.com>2020-05-10 22:32:34 +0800
commit3b8b6d837e49bb6a7111b866b2a9180577e67901 (patch)
tree7c4e21252f3a8a8ba8b369679f46ceb863952d15 /libavformat/http.c
parent53c88355a5ae638b3a3cf93508c4741238dc6c7f (diff)
downloadffmpeg-3b8b6d837e49bb6a7111b866b2a9180577e67901.tar.gz
avformat/http: Fix for invalid use of av_strtok
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
Diffstat (limited to 'libavformat/http.c')
-rw-r--r--libavformat/http.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/libavformat/http.c b/libavformat/http.c
index c9415578aa..20545ed1f8 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -786,6 +786,7 @@ static int parse_set_cookie_expiry_time(const char *exp_str, struct tm *buf)
static int parse_set_cookie(const char *set_cookie, AVDictionary **dict)
{
char *param, *next_param, *cstr, *back;
+ char *saveptr = NULL;
if (!set_cookie[0])
return 0;
@@ -803,8 +804,9 @@ static int parse_set_cookie(const char *set_cookie, AVDictionary **dict)
}
next_param = cstr;
- while ((param = av_strtok(next_param, ";", &next_param))) {
+ while ((param = av_strtok(next_param, ";", &saveptr))) {
char *name, *value;
+ next_param = NULL;
param += strspn(param, WHITESPACES);
if ((name = av_strtok(param, "=", &value))) {
if (av_dict_set(dict, name, value, 0) < 0) {
@@ -1064,6 +1066,7 @@ static int get_cookies(HTTPContext *s, char **cookies, const char *path,
// Set-Cookie fields will result in multiple values delimited by a newline
int ret = 0;
char *cookie, *set_cookies, *next;
+ char *saveptr = NULL;
// destroy any cookies in the dictionary.
av_dict_free(&s->cookie_dict);
@@ -1076,10 +1079,11 @@ static int get_cookies(HTTPContext *s, char **cookies, const char *path,
return AVERROR(ENOMEM);
*cookies = NULL;
- while ((cookie = av_strtok(next, "\n", &next)) && !ret) {
+ while ((cookie = av_strtok(next, "\n", &saveptr)) && !ret) {
AVDictionary *cookie_params = NULL;
AVDictionaryEntry *cookie_entry, *e;
+ next = NULL;
// store the cookie in a dict in case it is updated in the response
if (parse_cookie(s, cookie, &s->cookie_dict))
av_log(s, AV_LOG_WARNING, "Unable to parse '%s'\n", cookie);