[FFmpeg-devel] [PATCH] Ignore expired cookies
Michael Niedermayer
michael at niedermayer.cc
Tue Apr 25 12:38:40 EEST 2017
On Sat, Apr 08, 2017 at 09:05:46PM -0400, Micah Galizia wrote:
> Signed-off-by: Micah Galizia <micahgalizia at gmail.com>
> ---
> libavformat/http.c | 211 ++++++++++++++++++++++++++++++++++++++---------------
> 1 file changed, 154 insertions(+), 57 deletions(-)
>
> diff --git a/libavformat/http.c b/libavformat/http.c
> index 293a8a7204..425711aab5 100644
> --- a/libavformat/http.c
> +++ b/libavformat/http.c
> @@ -29,6 +29,7 @@
> #include "libavutil/avstring.h"
> #include "libavutil/opt.h"
> #include "libavutil/time.h"
> +#include "libavutil/parseutils.h"
>
> #include "avformat.h"
> #include "http.h"
> @@ -48,6 +49,8 @@
> #define MAX_REDIRECTS 8
> #define HTTP_SINGLE 1
> #define HTTP_MUTLI 2
> +#define MAX_EXPIRY 19
> +#define WHITESPACES " \n\t\r"
> typedef enum {
> LOWER_PROTO,
> READ_HEADERS,
> @@ -680,10 +683,109 @@ static int parse_icy(HTTPContext *s, const char *tag, const char *p)
> return 0;
> }
>
> +static int parse_set_cookie_expiry_time(const char *exp_str, struct tm *buf)
> +{
> + char exp_buf[MAX_EXPIRY];
> + int i, j, exp_buf_len = MAX_EXPIRY-1;
> + char *expiry;
> +
> + // strip off any punctuation or whitespace
> + for (i = 0, j = 0; exp_str[i] != '\0' && j < exp_buf_len; i++) {
> + if ((exp_str[i] >= '0' && exp_str[i] <= '9') ||
> + (exp_str[i] >= 'A' && exp_str[i] <= 'Z') ||
> + (exp_str[i] >= 'a' && exp_str[i] <= 'z')) {
> + exp_buf[j] = exp_str[i];
> + j++;
> + }
> + }
> + exp_buf[j] = '\0';
> + expiry = exp_buf;
> +
> + // move the string beyond the day of week
> + while ((*expiry < '0' || *expiry > '9') && *expiry != '\0')
> + expiry++;
> +
> + return av_small_strptime(expiry, "%d%b%Y%H%M%S", buf) ? 0 : AVERROR(EINVAL);
> +}
> +
> +static int parse_set_cookie(const char *set_cookie, AVDictionary **dict)
> +{
> + char *param, *next_param, *cstr, *back;
> +
> + if (!(cstr = av_strdup(set_cookie)))
> + return AVERROR(EINVAL);
> +
> + // strip any trailing whitespace
> + back = &cstr[strlen(cstr)-1];
> + while (strchr(WHITESPACES, *back)) {
> + *back='\0';
> + back--;
> + }
> +
> + next_param = cstr;
> + while ((param = av_strtok(next_param, ";", &next_param))) {
> + char *name, *value;
> + param += strspn(param, WHITESPACES);
> + if ((name = av_strtok(param, "=", &value))) {
> + av_dict_set(dict, name, value, 0);
missing failure check
also if you get no reviewes of patches and are interrested in
the code, try to suggest to help with maintaining it, if noone objects
send a patch that adds you to MAINTAINERs
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
It is what and why we do it that matters, not just one of them.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20170425/14d11b1d/attachment.sig>
More information about the ffmpeg-devel
mailing list