Re: [E-devel] [EGIT] [core/enlightenment] master 01/01: protect against non-nul terminated string from mmap in filepreview

2016-09-23 Thread The Rasterman
On Wed, 21 Sep 2016 16:52:31 -0700 Cedric BAIL  said:

> On Wed, Sep 21, 2016 at 4:32 PM, Carsten Haitzler 
> wrote:
> > On Wed, 21 Sep 2016 08:33:11 -0700 Cedric BAIL  said:
> >> On Sep 21, 2016 4:18 AM, "Carsten Haitzler"  wrote:
> >> > raster pushed a commit to branch master.
> >> >
> >> >
> >> http://git.enlightenment.org/core/enlightenment.git/commit/?id=5861d9bef949c64cbc7ddad31b4ac2cc70bb6440
> >> >
> >> > commit 5861d9bef949c64cbc7ddad31b4ac2cc70bb6440
> >> > Author: Carsten Haitzler (Rasterman) 
> >> > Date:   Wed Sep 21 20:18:01 2016 +0900
> >> >
> >> > protect against non-nul terminated string from mmap in filepreview
> >> >
> >> > this should address 2nd gdb bt and fix T4543
> >>
> >> No ! This patch is unnecessary or more exactly too late. Previous code was
> >> using the _n variant of append which call strlen. The current code only
> >> rely on the given length. Will revert.
> >
> > why on earth is it doing strlen when obviously n bytes are to go in (or
> > until the nul byte)?
> 
> It is the same difference as memcpy and strncpy. One take the original
> pointer as just data, the other as a string. So the _n variant is the
> one that does call strlen to get the max number of character to copy.

shouldnt it walk UP to n and if it sees a 0 byte before that... take that as
len otherwise take given length n as len?


-- 
- Codito, ergo sum - "I code, therefore I am" --
The Rasterman (Carsten Haitzler)ras...@rasterman.com


--
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


Re: [E-devel] [EGIT] [core/enlightenment] master 01/01: protect against non-nul terminated string from mmap in filepreview

2016-09-21 Thread Cedric BAIL
On Wed, Sep 21, 2016 at 4:32 PM, Carsten Haitzler  wrote:
> On Wed, 21 Sep 2016 08:33:11 -0700 Cedric BAIL  said:
>> On Sep 21, 2016 4:18 AM, "Carsten Haitzler"  wrote:
>> > raster pushed a commit to branch master.
>> >
>> >
>> http://git.enlightenment.org/core/enlightenment.git/commit/?id=5861d9bef949c64cbc7ddad31b4ac2cc70bb6440
>> >
>> > commit 5861d9bef949c64cbc7ddad31b4ac2cc70bb6440
>> > Author: Carsten Haitzler (Rasterman) 
>> > Date:   Wed Sep 21 20:18:01 2016 +0900
>> >
>> > protect against non-nul terminated string from mmap in filepreview
>> >
>> > this should address 2nd gdb bt and fix T4543
>>
>> No ! This patch is unnecessary or more exactly too late. Previous code was
>> using the _n variant of append which call strlen. The current code only
>> rely on the given length. Will revert.
>
> why on earth is it doing strlen when obviously n bytes are to go in (or until
> the nul byte)?

It is the same difference as memcpy and strncpy. One take the original
pointer as just data, the other as a string. So the _n variant is the
one that does call strlen to get the max number of character to copy.
-- 
Cedric BAIL

--
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


Re: [E-devel] [EGIT] [core/enlightenment] master 01/01: protect against non-nul terminated string from mmap in filepreview

2016-09-21 Thread The Rasterman
On Wed, 21 Sep 2016 08:33:11 -0700 Cedric BAIL  said:

> On Sep 21, 2016 4:18 AM, "Carsten Haitzler"  wrote:
> >
> > raster pushed a commit to branch master.
> >
> >
> http://git.enlightenment.org/core/enlightenment.git/commit/?id=5861d9bef949c64cbc7ddad31b4ac2cc70bb6440
> >
> > commit 5861d9bef949c64cbc7ddad31b4ac2cc70bb6440
> > Author: Carsten Haitzler (Rasterman) 
> > Date:   Wed Sep 21 20:18:01 2016 +0900
> >
> > protect against non-nul terminated string from mmap in filepreview
> >
> > this should address 2nd gdb bt and fix T4543
> 
> No ! This patch is unnecessary or more exactly too late. Previous code was
> using the _n variant of append which call strlen. The current code only
> rely on the given length. Will revert.

why on earth is it doing strlen when obviously n bytes are to go in (or until
the nul byte)?

> > @fix
> > ---
> >  src/bin/e_widget_filepreview.c | 7 ++-
> >  1 file changed, 6 insertions(+), 1 deletion(-)
> >
> > diff --git a/src/bin/e_widget_filepreview.c
> b/src/bin/e_widget_filepreview.c
> > index 2602895..1f91073 100644
> > --- a/src/bin/e_widget_filepreview.c
> > +++ b/src/bin/e_widget_filepreview.c
> > @@ -931,8 +931,13 @@ _e_wid_fprev_preview_txt_map_success(void *data,
> Eio_File *handler EINA_UNUSED,
> > char *msg;
> > Evas_Coord mw, mh;
> >
> > +   msg = malloc(length + 1);
> > +   if (!msg) return;
> > +   strncpy(msg, map, length);
> > +   msg[length] = 0;
> > buf = eina_strbuf_new();
> > -   eina_strbuf_append_length(buf, map, length);
> > +   eina_strbuf_append_length(buf, msg, length);
> > +   free(msg);
> > msg = evas_textblock_text_utf8_to_markup(NULL,
> eina_strbuf_string_get(buf));
> > eina_strbuf_reset(buf);
> >
> >
> > --
> >
> >
> --
> ___
> enlightenment-devel mailing list
> enlightenment-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
> 


-- 
- Codito, ergo sum - "I code, therefore I am" --
The Rasterman (Carsten Haitzler)ras...@rasterman.com


--
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


Re: [E-devel] [EGIT] [core/enlightenment] master 01/01: protect against non-nul terminated string from mmap in filepreview

2016-09-21 Thread Cedric BAIL
On Sep 21, 2016 4:18 AM, "Carsten Haitzler"  wrote:
>
> raster pushed a commit to branch master.
>
>
http://git.enlightenment.org/core/enlightenment.git/commit/?id=5861d9bef949c64cbc7ddad31b4ac2cc70bb6440
>
> commit 5861d9bef949c64cbc7ddad31b4ac2cc70bb6440
> Author: Carsten Haitzler (Rasterman) 
> Date:   Wed Sep 21 20:18:01 2016 +0900
>
> protect against non-nul terminated string from mmap in filepreview
>
> this should address 2nd gdb bt and fix T4543

No ! This patch is unnecessary or more exactly too late. Previous code was
using the _n variant of append which call strlen. The current code only
rely on the given length. Will revert.

> @fix
> ---
>  src/bin/e_widget_filepreview.c | 7 ++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/src/bin/e_widget_filepreview.c
b/src/bin/e_widget_filepreview.c
> index 2602895..1f91073 100644
> --- a/src/bin/e_widget_filepreview.c
> +++ b/src/bin/e_widget_filepreview.c
> @@ -931,8 +931,13 @@ _e_wid_fprev_preview_txt_map_success(void *data,
Eio_File *handler EINA_UNUSED,
> char *msg;
> Evas_Coord mw, mh;
>
> +   msg = malloc(length + 1);
> +   if (!msg) return;
> +   strncpy(msg, map, length);
> +   msg[length] = 0;
> buf = eina_strbuf_new();
> -   eina_strbuf_append_length(buf, map, length);
> +   eina_strbuf_append_length(buf, msg, length);
> +   free(msg);
> msg = evas_textblock_text_utf8_to_markup(NULL,
eina_strbuf_string_get(buf));
> eina_strbuf_reset(buf);
>
>
> --
>
>
--
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


[EGIT] [core/enlightenment] master 01/01: protect against non-nul terminated string from mmap in filepreview

2016-09-21 Thread Carsten Haitzler
raster pushed a commit to branch master.

http://git.enlightenment.org/core/enlightenment.git/commit/?id=5861d9bef949c64cbc7ddad31b4ac2cc70bb6440

commit 5861d9bef949c64cbc7ddad31b4ac2cc70bb6440
Author: Carsten Haitzler (Rasterman) 
Date:   Wed Sep 21 20:18:01 2016 +0900

protect against non-nul terminated string from mmap in filepreview

this should address 2nd gdb bt and fix T4543

@fix
---
 src/bin/e_widget_filepreview.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/bin/e_widget_filepreview.c b/src/bin/e_widget_filepreview.c
index 2602895..1f91073 100644
--- a/src/bin/e_widget_filepreview.c
+++ b/src/bin/e_widget_filepreview.c
@@ -931,8 +931,13 @@ _e_wid_fprev_preview_txt_map_success(void *data, Eio_File 
*handler EINA_UNUSED,
char *msg;
Evas_Coord mw, mh;
 
+   msg = malloc(length + 1);
+   if (!msg) return;
+   strncpy(msg, map, length);
+   msg[length] = 0;
buf = eina_strbuf_new();
-   eina_strbuf_append_length(buf, map, length);
+   eina_strbuf_append_length(buf, msg, length);
+   free(msg);
msg = evas_textblock_text_utf8_to_markup(NULL, eina_strbuf_string_get(buf));
eina_strbuf_reset(buf);
 

--