Bug 145596 - [EFL][GTK] Fix build error since r185137
Summary: [EFL][GTK] Fix build error since r185137
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Gyuyoung Kim
URL:
Keywords:
Depends on: 145283
Blocks:
  Show dependency treegraph
 
Reported: 2015-06-02 23:08 PDT by Hyungwook Lee
Modified: 2015-06-03 17:15 PDT (History)
6 users (show)

See Also:


Attachments
Patch (1.17 KB, patch)
2015-06-02 23:10 PDT, Gyuyoung Kim
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Hyungwook Lee 2015-06-02 23:08:25 PDT
r185137 used strlcpy() even though it is not standardized by POSIX. It caused build break on GTK and EFL port's debug build. To fix it, let's use strncpy() in Text.cpp.
Comment 1 Gyuyoung Kim 2015-06-02 23:10:25 PDT
Created attachment 254154 [details]
Patch
Comment 2 WebKit Commit Bot 2015-06-02 23:13:35 PDT
Comment on attachment 254154 [details]
Patch

Rejecting attachment 254154 [details] from commit-queue.

hyungwook.lee@navercorp.com does not have committer permissions according to http://trac.webkit.org/browser/trunk/Tools/Scripts/webkitpy/common/config/contributors.json.

- If you do not have committer rights please read http://webkit.org/coding/contributing.html for instructions on how to use bugzilla flags.

- If you have committer rights please correct the error in Tools/Scripts/webkitpy/common/config/contributors.json by adding yourself to the file (no review needed).  The commit-queue restarts itself every 2 hours.  After restart the commit-queue will correctly respect your committer rights.
Comment 3 Gyuyoung Kim 2015-06-02 23:17:44 PDT
I uploaded this patch instead of Hyungwook.
Comment 4 Gyuyoung Kim 2015-06-02 23:59:10 PDT
Comment on attachment 254154 [details]
Patch

Clearing flags on attachment: 254154

Committed r185148: <http://trac.webkit.org/changeset/185148>
Comment 5 Gyuyoung Kim 2015-06-02 23:59:17 PDT
All reviewed patches have been landed.  Closing bug.
Comment 6 Michael Catanzaro 2015-06-03 08:05:59 PDT
I think this is a buffer overflow; it should be strncpy(buffer, result.toString().utf8().data(), length - 1) as it was prior to r185137.

From strcpy(3):

   strlcpy()
       Some  systems  (the  BSDs,  Solaris,  and others) provide the following
       function:

           size_t strlcpy(char *dest, const char *src, size_t size);

       This function is similar to strncpy(), but it  copies  at  most  size-1
       bytes  to  dest,  always adds a terminating null byte, and does not pad
       the target with (further) null bytes.  This function fixes some of  the
       problems  of  strcpy()  and strncpy(), but the caller must still handle
       the possibility of data loss if size is too small.  The return value of
       the function is the length of src, which allows truncation to be easily
       detected: if the return value is greater than or equal to size, trunca‐
       tion  occurred.   If loss of data matters, the caller must either check
       the arguments before the call,  or  test  the  function  return  value.
       strlcpy() is not present in glibc and is not standardized by POSIX, but
       is available on Linux via the libbsd library.
Comment 7 Michael Catanzaro 2015-06-03 09:59:07 PDT
Let's use bug #145608
Comment 8 Gyuyoung Kim 2015-06-03 17:15:56 PDT
(In reply to comment #6)
> I think this is a buffer overflow; it should be strncpy(buffer,
> result.toString().utf8().data(), length - 1) as it was prior to r185137.
> 
> From strcpy(3):
> 
>    strlcpy()
>        Some  systems  (the  BSDs,  Solaris,  and others) provide the
> following
>        function:
> 
>            size_t strlcpy(char *dest, const char *src, size_t size);
> 
>        This function is similar to strncpy(), but it  copies  at  most 
> size-1
>        bytes  to  dest,  always adds a terminating null byte, and does not
> pad
>        the target with (further) null bytes.  This function fixes some of 
> the
>        problems  of  strcpy()  and strncpy(), but the caller must still
> handle
>        the possibility of data loss if size is too small.  The return value
> of
>        the function is the length of src, which allows truncation to be
> easily
>        detected: if the return value is greater than or equal to size,
> trunca‐
>        tion  occurred.   If loss of data matters, the caller must either
> check
>        the arguments before the call,  or  test  the  function  return 
> value.
>        strlcpy() is not present in glibc and is not standardized by POSIX,
> but
>        is available on Linux via the libbsd library.

Oh, thank you for your fix.