From: Eryu Guan <guaneryu@gmail.com>
To: zab@redhat.com
Cc: linux-btrfs@vger.kernel.org, Eryu Guan <guaneryu@gmail.com>
Subject: Re: [PATCH v2] btrfs-progs: fix segfault when listing column OTIME on big endian host
Date: Fri, 26 Jul 2013 12:34:18 +0800 [thread overview]
Message-ID: <1374813258-25503-1-git-send-email-guaneryu@gmail.com> (raw)
In-Reply-To: <20130725212531.GJ26554@lenny.home.zabbo.net>
On Fri, Jul 26, 2013 at 5:25 AM, Zach Brown <zab@redhat.com> wrote:
>> btrfs-list.c:
>> case BTRFS_LIST_OTIME:
>> if (subv->otime)
>> strftime(tstr, 256, "%Y-%m-%d %X",
>> localtime(&subv->otime));
>> else
>> strcpy(tstr, "-");
>> printf("%s", tstr);
>> break;
>>
>> localtime() returned NULL then strftime() got SIGSEGV.
>>
>> The reason is that ri->otime.sec is stored as little endian but
>> assigned to 't' without conversion.
>
> That's why localtime() returned null, sure, but it doesn't excuse
> strftime() being called with a null *tm! Add some error checking around
> localtime(). It should warn that otime is nonsense, not crash.
>
Yes, return value of localtime() should be checked. There're other
places call localtime() or localtime_r() without checking the return
value, I think another patch could fix them all and leave this patch
to fix the root cause.
Thanks,
Eryu Guan
next prev parent reply other threads:[~2013-07-26 4:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-25 9:32 [PATCH] btrfs-progs: fix segfault when listing column OTIME on big endian host Eryu Guan
2013-07-25 11:21 ` Miao Xie
2013-07-25 14:12 ` [PATCH v2] " Eryu Guan
2013-07-25 21:25 ` Zach Brown
2013-07-26 4:34 ` Eryu Guan [this message]
2013-08-01 21:08 ` David Sterba
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=1374813258-25503-1-git-send-email-guaneryu@gmail.com \
--to=guaneryu@gmail.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=zab@redhat.com \
/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.