[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH v2 3/4] Validate the bios_date format for <sysinfo>



On 05/14/2013 04:22 AM, John Ferlan wrote:
> On 05/13/2013 03:51 PM, Eric Blake wrote:
>> On 05/13/2013 11:01 AM, John Ferlan wrote:
>>> Add incorrectly formatted bios_date validation test
>>> ---
> 
> In any case, in lieu of a v3, here's a diff:

Thanks; that works.


> or more visually appealing
> 
>     if (def->bios_date != NULL) {
>         char *ptr;
>         int month, day, year;
> 
>         /* Validate just the format of the date
>          * Expect mm/dd/yyyy or mm/dd/yy,
>          * where yy must be 00->99 and would be assumed to be 19xx
>          * a yyyy date should be 1900 and beyond
>          */
>         if (virStrToLong_i(def->bios_date, &ptr, 10, &month) < 0 ||
>             *ptr != '/' ||
>             virStrToLong_i(ptr + 1, &ptr, 10, &day) < 0 ||
>             *ptr != '/' ||
>             virStrToLong_i(ptr + 1, &ptr, 10, &year) < 0 ||
>             *ptr != '\0' ||
>             (month < 1 || month > 12) ||
>             (day < 1 || day > 31) ||
>             (year < 0 || (year >= 100 && year < 1900))) {
>             virReportError(VIR_ERR_XML_DETAIL, "%s",
>                            _("Invalid BIOS 'date' format"));
>             goto error;
>         }
>     }

Indeed, that removes any confusion I had.  ACK with this squashed in to
the rest of your v3 patch.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]