All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexandra Yates <alexandra.yates at linux.intel.com>
To: powertop@lists.01.org
Subject: Re: [Powertop] [PATCH 1/2] prevent segment fault for android built 2
Date: Thu, 17 Sep 2015 17:21:18 -0700	[thread overview]
Message-ID: <55FB58FE.3070800@linux.intel.com> (raw)
In-Reply-To: CAN2waFs38gP+34_0hnidXW0TPA29hDT=jropbkZO+NHrVYq5bw@mail.gmail.com

[-- Attachment #1: Type: text/plain, Size: 2788 bytes --]

Rejecting this patch.  This is already handled on the Android patches.

On 07/06/2015 07:16 PM, Zhaoyang Huang wrote:
> Hi Daniel,
> Thank you for your feedback.
> I have noticed the patch you mentioned. However, under the android(use 
> bionic libc) environment, the bellowing condition maybe true which 
> will cause a NULL pointer access to buffer. I add another one more 
> condition to prevent it. This problem can also be reproduced by android.
>
> diff --git a/src/lib.cpp b/src/lib.cpp
> index 88fe5f3..8d1ca9f 100644
> --- a/src/lib.cpp
> +++ b/src/lib.cpp
> @@ -285,7 +285,7 @@ void align_string(char *buffer, size_t min_sz, 
> size_t max_sz)
>         /* start with mbsrtowcs() local mbstate_t * and
>          * NULL dst pointer*/
>         sz = mbsrtowcs(NULL, (const char **)&buffer, max_sz, NULL);
> -       if (sz == (size_t)-1) {
> +       if ((sz == (size_t)-1) && (NULL != buffer)) {
>                 buffer[min_sz] = 0x00;
>                 return;
>         }
> -- 
> 1.7.9.5
>
>
> On 7 July 2015 at 05:44, Daniel Leung <daniel.leung(a)linux.intel.com 
> <mailto:daniel.leung(a)linux.intel.com>> wrote:
>
>     On Wed,  1 Jul 2015 19:52:24 +0800
>     Zhaoyang Huang <zhaoyang.huang(a)linaro.org
>     <mailto:zhaoyang.huang(a)linaro.org>> wrote:
>
>     > the buffer will be turn into NULL after invoking the mbsrtowcs
>     function
>     > of bionic libc. Add a condition judgement for that
>     >
>     > Signed-off-by: Zhaoyang Huang <zhaoyang.huang(a)linaro.org
>     <mailto:zhaoyang.huang(a)linaro.org>>
>     > ---
>     >  src/lib.cpp |    2 +-
>     >  1 file changed, 1 insertion(+), 1 deletion(-)
>     >
>     > diff --git a/src/lib.cpp b/src/lib.cpp
>     > index 88fe5f3..8d1ca9f 100644
>     > --- a/src/lib.cpp
>     > +++ b/src/lib.cpp
>     > @@ -285,7 +285,7 @@ void align_string(char *buffer, size_t
>     min_sz, size_t max_sz)
>     >       /* start with mbsrtowcs() local mbstate_t * and
>     >        * NULL dst pointer*/
>     >       sz = mbsrtowcs(NULL, (const char **)&buffer, max_sz, NULL);
>     > -     if (sz == (size_t)-1) {
>     > +     if ((sz == (size_t)-1) && (NULL != buffer)) {
>     >               buffer[min_sz] = 0x00;
>     >               return;
>     >       }
>     > --
>     > 1.7.9.5
>     >
>
>     If you are on master branch, there is a patch
>     (patches/android/prevent_segfaults.patch) to workaround the NULL
>     pointer.
>
>     --
>     Daniel Leung <daniel.leung(a)linux.intel.com
>     <mailto:daniel.leung(a)linux.intel.com>>
>
>
>
>
> _______________________________________________
> PowerTop mailing list
> PowerTop(a)lists.01.org
> https://lists.01.org/mailman/listinfo/powertop

-- 
Thank you,
<Alexandra>


             reply	other threads:[~2015-09-18  0:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-18  0:21 Alexandra Yates [this message]
  -- strict thread matches above, loose matches on Subject: below --
2015-07-07  2:16 [Powertop] [PATCH 1/2] prevent segment fault for android built 2 Zhaoyang Huang
2015-07-06 21:44 Daniel Leung
2015-07-01 11:52 Zhaoyang Huang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55FB58FE.3070800@linux.intel.com \
    --to=powertop@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.