On Fri, Jul 26, 2013 at 5:25 AM, Zach Brown <zab@xxxxxxxxxx> 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
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html