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

Eric Blake eblake at redhat.com
Wed May 15 16:05:41 UTC 2013


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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130515/4f4aabb8/attachment-0001.sig>


More information about the libvir-list mailing list