All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jennifer Herbert <Jennifer.Herbert@citrix.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>, xen-devel@lists.xen.org
Cc: ian.jackson@eu.citrix.com, wei.liu2@citrix.com,
	ian.campbell@citrix.com, stefano.stabellini@eu.citrix.com
Subject: Re: [PATCH V2] libxc: Prevent NULL pointer dereference in stdiostream_vmessage()
Date: Tue, 7 Jul 2015 17:08:20 +0100	[thread overview]
Message-ID: <559BF974.2050700@citrix.com> (raw)
In-Reply-To: <559BF57C.1050608@citrix.com>

I guess I didn't build what I thought I built.
V3 coming up

On 07/07/15 16:51, Andrew Cooper wrote:
> On 07/07/15 16:48, Jennifer Herbert wrote:
>> Unlikely that it may seem localtime_r could fail, which would result in a
>> null pointer dereference.  In this case, it shoud log the errno, (instead of
>> the date/time), and and continue its logging, as this is still useful.
>>
>> Signed-off-by: Jennifer Herbert <jennifer.herbert@citrix.com>
>> ---
>>   tools/libxc/xtl_logger_stdio.c |   11 +++++++----
>>   1 file changed, 7 insertions(+), 4 deletions(-)
>>
>> diff --git a/tools/libxc/xtl_logger_stdio.c b/tools/libxc/xtl_logger_stdio.c
>> index d8646e0..5569c50 100644
>> --- a/tools/libxc/xtl_logger_stdio.c
>> +++ b/tools/libxc/xtl_logger_stdio.c
>> @@ -61,10 +61,13 @@ static void stdiostream_vmessage(xentoollog_logger *logger_in,
>>           struct tm lt_buf;
>>           time_t now = time(0);
>>           struct tm *lt= localtime_r(&now, &lt_buf);
>> -        fprintf(lg->f, "%04d-%02d-%02d %02d:%02d:%02d %s ",
>> -                lt->tm_year+1900, lt->tm_mon+1, lt->tm_mday,
>> -                lt->tm_hour, lt->tm_min, lt->tm_sec,
>> -                tzname[!!lt->tm_isdst]);
>> +        if (lt != NULL)
>> +            fprintf(lg->f, "%04d-%02d-%02d %02d:%02d:%02d %s ",
>> +                    lt->tm_year+1900, lt->tm_mon+1, lt->tm_mday,
>> +                    lt->tm_hour, lt->tm_min, lt->tm_sec,
>> +                    tzname[!!lt->tm_isdst]);
>> +        else
>> +            fprintf(lg-f, "[localtime_r failed: %d] ", errno);
> lg->f ?
>
> ~Andrew
>
>>       }
>>       if (lg->flags & XTL_STDIOSTREAM_SHOW_PID)
>>           fprintf(lg->f, "[%lu] ", (unsigned long)getpid());

  parent reply	other threads:[~2015-07-07 16:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-07 15:48 [PATCH V2] libxc: Prevent NULL pointer dereference in stdiostream_vmessage() Jennifer Herbert
2015-07-07 15:51 ` Andrew Cooper
2015-07-07 16:05   ` Ian Jackson
2015-07-07 16:13     ` Jennifer Herbert
2015-07-07 16:08   ` Jennifer Herbert [this message]
2015-07-07 16:04 ` Ian Jackson

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=559BF974.2050700@citrix.com \
    --to=jennifer.herbert@citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.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.