From 4277658ea6ce6c95006031287bd2cc792fac666b Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Fri, 14 Oct 2005 23:18:12 +0000 Subject: [PATCH] Remove two-digit limitation on days in log purge interval --- servers/slapd/overlays/accesslog.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/servers/slapd/overlays/accesslog.c b/servers/slapd/overlays/accesslog.c index 9b35ac8805..30f9553f67 100644 --- a/servers/slapd/overlays/accesslog.c +++ b/servers/slapd/overlays/accesslog.c @@ -346,22 +346,23 @@ static struct { #define RDNEQ "reqStart=" -/* Our time intervals are of the form [dd+]hh:mm[:ss] - * If a field is present, it must be two digits. We assume no one - * will want to keep log records for longer than 99 days. +/* Our time intervals are of the form [ddd+]hh:mm[:ss] + * If a field is present, it must be two digits. (Except for + * days, which can be arbitrary width.) */ static int log_age_parse(char *agestr) { int t1, t2; int gotdays = 0; + char *endptr; - t1 = atoi( agestr ); + t1 = strtol( agestr, &endptr, 10 ); /* Is there a days delimiter? */ - if ( agestr[2] == '+' ) { + if ( *endptr == '+' ) { t1 *= 24; gotdays = 1; - } else if ( agestr[2] != ':' ) { + } else if ( *endptr != ':' ) { /* No valid delimiter found, fail */ return -1; } @@ -421,7 +422,7 @@ log_age_unparse( int age, struct berval *agebv ) ptr = agebv->bv_val; if ( dd ) - ptr += sprintf( ptr, "%02d+", dd ); + ptr += sprintf( ptr, "%d+", dd ); ptr += sprintf( ptr, "%02d:%02d", hh, mm ); if ( ss ) ptr += sprintf( ptr, ":%02d", ss ); -- 2.39.5