even more tests for invalid fractions

This commit is contained in:
Lev Walkin 2005-07-04 02:20:26 +00:00
parent d4e4e612d9
commit 10dd97c70c
2 changed files with 16 additions and 2 deletions

View File

@ -561,8 +561,7 @@ asn_time2GT_frac(GeneralizedTime_t *opt_gt, const struct tm *tm, long frac_value
*/
if(frac_base >= 10
&& frac_value > 0
/* 1001 ms? should ignore or adjust seconds */
&& (frac_value/frac_base) == 0
&& (frac_value/(frac_base/10)) < 10 /* 98/99 */
) {
char *end = p + 1 + 6; /* '.' + maximum 6 digits */
char *z = p;

View File

@ -133,6 +133,21 @@ check_fractions() {
printf("[%s]\n", gt->buf);
assert(strcmp((char *)gt->buf, "19700101000000Z") == 0);
gt = asn_time2GT_frac(gt, &tm, 98, 99, 1);
assert(gt);
printf("[%s]\n", gt->buf);
assert(strcmp((char *)gt->buf, "19700101000000Z") == 0);
gt = asn_time2GT_frac(gt, &tm, 90, 91, 1);
assert(gt);
printf("[%s]\n", gt->buf);
assert(strcmp((char *)gt->buf, "19700101000000Z") == 0);
gt = asn_time2GT_frac(gt, &tm, 89, 91, 1);
assert(gt);
printf("[%s]\n", gt->buf);
assert(strcmp((char *)gt->buf, "19700101000000.9Z") == 0);
FREEMEM(gt->buf);
FREEMEM(gt);
}