[FFmpeg-devel] [PATCH v4] Parse cookies more correctly

Michael Niedermayer michaelni at gmx.at
Fri Feb 21 15:24:42 CET 2014


On Thu, Feb 20, 2014 at 10:42:55PM -0800, Scott Moak wrote:
> Cookies with an Expires directive do not get parsed (and ignored)
> correctly, so we need to fix that.
> 
> Signed-off-by: Scott Moak <scott.moak at mybrainoncode.com>
> ---
>  libavformat/http.c | 15 ++++++++++++---
>  1 file changed, 12 insertions(+), 3 deletions(-)
> 
> diff --git a/libavformat/http.c b/libavformat/http.c
> index 69c4d6d..3d9563b 100644
> --- a/libavformat/http.c
> +++ b/libavformat/http.c
> @@ -484,8 +484,16 @@ static int get_cookies(HTTPContext *s, char **cookies, const char *path,
>          char *param, *next_param, *cdomain = NULL, *cpath = NULL, *cvalue = NULL;
>          set_cookies = NULL;
>  
> -        while ((param = av_strtok(cookie, "; ", &next_param))) {
> +        while ((param = av_strtok(cookie, ";", &next_param))) {
>              cookie = NULL;
> +            /* skip leading spaces */
> +            param += strspn(param, " ");
> +            /* skip trailing spaces */

> +            if (strlen(param) > 0) {
> +                while (0x20 == param[strlen(param) - 1]) {
> +                    param[strlen(param) - 1] = 0;
> +                }
> +            }

this can still read and write out of array

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Awnsering whenever a program halts or runs forever is
On a turing machine, in general impossible (turings halting problem).
On any real computer, always possible as a real computer has a finite number
of states N, and will either halt in less than N cycles or never halt.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140221/8693d404/attachment.asc>


More information about the ffmpeg-devel mailing list