2875. [bug] dns_time64_fromtext() could accept non digits.

[RT #21033]
This commit is contained in:
Mark Andrews
2010-04-21 02:21:31 +00:00
parent 592a269a64
commit cc6d67469c
2 changed files with 13 additions and 1 deletions

View File

@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: time.c,v 1.33 2009/01/17 23:47:43 tbox Exp $ */
/* $Id: time.c,v 1.34 2010/04/21 02:21:31 marka Exp $ */
/*! \file */
@@ -24,6 +24,7 @@
#include <stdio.h>
#include <isc/string.h> /* Required for HP/UX (and others?) */
#include <time.h>
#include <ctype.h>
#include <isc/print.h>
#include <isc/region.h>
@@ -132,6 +133,14 @@ dns_time64_fromtext(const char *source, isc_int64_t *target) {
if (strlen(source) != 14U)
return (DNS_R_SYNTAX);
/*
* Confirm the source only consists digits. sscanf() allows some
* minor exceptions.
*/
for (i = 0; i < 14; i++) {
if (!isdigit((unsigned char)source[i]))
return (DNS_R_SYNTAX);
}
if (sscanf(source, "%4d%2d%2d%2d%2d%2d",
&year, &month, &day, &hour, &minute, &second) != 6)
return (DNS_R_SYNTAX);