On Wed, Aug 03, 2011 at 12:21:44PM +0100, Edd Barrett wrote:
> Hi,
> 
> This fixes an annoying segfault bug that made the mailcap/mime support
> of elinks unusable about 33% of the time. It has been driving me crazy
> for some time and I use elinks a lot. Can it go in, or should this be
> put in post-lock?

It fixes a leak or a crash ? Is it one fix or two independant ones ?

Landry

> Index: Makefile
> ===================================================================
> RCS file: /cvs/ports/www/elinks/Makefile,v
> retrieving revision 1.28
> diff -u -p -u -r1.28 Makefile
> --- Makefile  11 Apr 2011 08:11:14 -0000      1.28
> +++ Makefile  3 Aug 2011 11:13:33 -0000
> @@ -2,7 +2,7 @@
>  
>  COMMENT=             full-featured text WWW browser
>  DISTNAME=            elinks-0.11.7
> -REVISION=            5
> +REVISION=            6
>  CATEGORIES=          www
>  MASTER_SITES=                http://elinks.cz/download/
>  
> Index: patches/patch-src_mime_backend_mailcap_c
> ===================================================================
> RCS file: patches/patch-src_mime_backend_mailcap_c
> diff -N patches/patch-src_mime_backend_mailcap_c
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-src_mime_backend_mailcap_c  3 Aug 2011 11:13:33 -0000
> @@ -0,0 +1,26 @@
> +$OpenBSD$
> +--- src/mime/backend/mailcap.c.orig  Sat Aug 22 12:15:08 2009
> ++++ src/mime/backend/mailcap.c       Wed Aug  3 01:14:40 2011
> +@@ -289,7 +289,11 @@ parse_optional_fields(struct mailcap_entry *entry, uns
> +                     entry->copiousoutput = 1;
> + 
> +             } else if (!c_strncasecmp(field, "test", 4)) {
> +-                    entry->testcommand = get_mailcap_field_text(field + 4);
> ++                    /* Don't leak memory if a corrupted mailcap
> ++                     * file has multiple test commands in the same
> ++                     * line.  */
> ++                    mem_free_set(&entry->testcommand,
> ++                                 get_mailcap_field_text(field + 4));
> +                     if (!entry->testcommand)
> +                             return 0;
> + 
> +@@ -301,7 +305,8 @@ parse_optional_fields(struct mailcap_entry *entry, uns
> +                             }
> + 
> +             } else if (!c_strncasecmp(field, "description", 11)) {
> +-                    entry->description = get_mailcap_field_text(field + 11);
> ++                    mem_free_set(&entry->description,
> ++                                 get_mailcap_field_text(field + 11));
> +                     if (!entry->description)
> +                             return 0;
> +             }
> Index: patches/patch-src_scripting_lua_core_c
> ===================================================================
> RCS file: /cvs/ports/www/elinks/patches/patch-src_scripting_lua_core_c,v
> retrieving revision 1.2
> diff -u -p -u -r1.2 patch-src_scripting_lua_core_c
> --- patches/patch-src_scripting_lua_core_c    21 Aug 2008 01:12:35 -0000      
> 1.2
> +++ patches/patch-src_scripting_lua_core_c    3 Aug 2011 11:13:33 -0000
> @@ -1,7 +1,7 @@
>  $OpenBSD: patch-src_scripting_lua_core_c,v 1.2 2008/08/21 01:12:35 sthen Exp 
> $
> ---- src/scripting/lua/core.c.orig    Fri Jun 20 21:19:55 2008
> -+++ src/scripting/lua/core.c Sat Aug  2 21:57:51 2008
> -@@ -641,7 +641,7 @@ do_hooks_file(LS, unsigned char *prefix, unsigned char
> +--- src/scripting/lua/core.c.orig    Sat Aug 22 12:15:08 2009
> ++++ src/scripting/lua/core.c Wed Aug  3 01:13:43 2011
> +@@ -645,7 +645,7 @@ do_hooks_file(LS, unsigned char *prefix, unsigned char
>       if (file_can_read(file)) {
>               int oldtop = lua_gettop(S);
>   
> @@ -10,7 +10,7 @@ $OpenBSD: patch-src_scripting_lua_core_c
>                       sleep(3); /* Let some time to see error messages. */
>               lua_settop(S, oldtop);
>       }
> -@@ -652,13 +652,24 @@ do_hooks_file(LS, unsigned char *prefix, unsigned char
> +@@ -656,13 +656,24 @@ do_hooks_file(LS, unsigned char *prefix, unsigned char
>   void
>   init_lua(struct module *module)
>   {
> @@ -40,7 +40,7 @@ $OpenBSD: patch-src_scripting_lua_core_c
>   
>       lua_register(L, LUA_ALERT, l_alert);
>       lua_register(L, "current_url", l_current_url);
> -@@ -763,7 +774,7 @@ handle_ret_eval(struct session *ses)
> +@@ -767,7 +778,7 @@ handle_ret_eval(struct session *ses)
>               int oldtop = lua_gettop(L);
>   
>               if (prepare_lua(ses) == 0) {
> Index: patches/patch-src_session_download_c
> ===================================================================
> RCS file: patches/patch-src_session_download_c
> diff -N patches/patch-src_session_download_c
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-src_session_download_c      3 Aug 2011 11:13:33 -0000
> @@ -0,0 +1,15 @@
> +$OpenBSD$
> +--- src/session/download.c.orig      Sat Aug 22 12:15:08 2009
> ++++ src/session/download.c   Wed Aug  3 01:14:40 2011
> +@@ -1090,10 +1090,7 @@ do_type_query(struct type_query *type_query, unsigned 
> +             }
> + 
> +             if (handler && handler->program) {
> +-                    int programlen = strlen(handler->program);
> +-
> +-                    programlen = int_max(programlen, MAX_STR_LEN);
> +-                    memcpy(field, handler->program, programlen);
> ++                    safe_strncpy(field, handler->program, MAX_STR_LEN);
> +             }
> + 
> +             /* xgettext:no-c-format */
> 
> -- 
> Best Regards
> Edd Barrett
> 
> http://www.theunixzoo.co.uk
> 

Reply via email to