From 007cbfc8f18e106daad1e99da6a5a815f4c2f58f Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Wed, 16 Sep 1998 08:33:34 +0000 Subject: [PATCH] Insert Y2K fix (hidden behind -DLDAP_Y2K). --- servers/slapd/add.c | 10 +++++++--- servers/slapd/modify.c | 10 +++++++--- servers/slapd/monitor.c | 22 +++++++++++++++++----- 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/servers/slapd/add.c b/servers/slapd/add.c index a4edb760ed..622d413c2a 100644 --- a/servers/slapd/add.c +++ b/servers/slapd/add.c @@ -145,7 +145,7 @@ do_add( conn, op ) static void add_created_attrs( Operation *op, Entry *e ) { - char buf[20]; + char buf[22]; struct berval bv; struct berval *bvals[2]; Attribute **a, **next; @@ -182,8 +182,12 @@ add_created_attrs( Operation *op, Entry *e ) attr_merge( e, "creatorsname", bvals ); pthread_mutex_lock( ¤ttime_mutex ); - ltm = localtime( ¤ttime ); - strftime( buf, sizeof(buf), "%y%m%d%H%M%SZ", ltm ); + ltm = localtime( ¤ttime ); +#ifdef LDAP_Y2K + strftime( buf, sizeof(buf), "%Y%m%d%H%M%SZ", ltm ); +#else + strftime( buf, sizeof(buf), "%y%m%d%H%M%SZ", ltm ); +#endif pthread_mutex_unlock( ¤ttime_mutex ); bv.bv_val = buf; diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index 75e2224a2c..dd7689cfaf 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -200,7 +200,7 @@ modlist_free( static void add_lastmods( Operation *op, LDAPMod **mods ) { - char buf[20]; + char buf[22]; struct berval bv; struct berval *bvals[2]; LDAPMod **m; @@ -251,8 +251,12 @@ add_lastmods( Operation *op, LDAPMod **mods ) *mods = tmp; pthread_mutex_lock( ¤ttime_mutex ); - ltm = localtime( ¤ttime ); - strftime( buf, sizeof(buf), "%y%m%d%H%M%SZ", ltm ); + ltm = localtime( ¤ttime ); +#ifdef LDAP_Y2K + strftime( buf, sizeof(buf), "%Y%m%d%H%M%SZ", ltm ); +#else + strftime( buf, sizeof(buf), "%y%m%d%H%M%SZ", ltm ); +#endif pthread_mutex_unlock( ¤ttime_mutex ); bv.bv_val = buf; bv.bv_len = strlen( bv.bv_val ); diff --git a/servers/slapd/monitor.c b/servers/slapd/monitor.c index 07ead7445d..f297b172d3 100644 --- a/servers/slapd/monitor.c +++ b/servers/slapd/monitor.c @@ -49,7 +49,7 @@ void monitor_info( Connection *conn, Operation *op ) { Entry *e; - char buf[BUFSIZ], buf2[20]; + char buf[BUFSIZ], buf2[22]; struct berval val; struct berval *vals[2]; int i, nconns, nwritewaiters, nreadwaiters; @@ -92,7 +92,11 @@ monitor_info( Connection *conn, Operation *op ) } pthread_mutex_lock( ¤ttime_mutex ); ltm = localtime( &c[i].c_starttime ); +#ifdef LDAP_Y2K + strftime( buf2, sizeof(buf2), "%Y%m%d%H%M%SZ", ltm ); +#else strftime( buf2, sizeof(buf2), "%y%m%d%H%M%SZ", ltm ); +#endif pthread_mutex_unlock( ¤ttime_mutex ); pthread_mutex_lock( &c[i].c_dnmutex ); @@ -155,16 +159,24 @@ monitor_info( Connection *conn, Operation *op ) attr_merge( e, "bytessent", vals ); pthread_mutex_lock( ¤ttime_mutex ); - ltm = localtime( ¤ttime ); - strftime( buf, sizeof(buf), "%y%m%d%H%M%SZ", ltm ); + ltm = localtime( ¤ttime ); +#ifdef LDAP_Y2K + strftime( buf, sizeof(buf), "%Y%m%d%H%M%SZ", ltm ); +#else + strftime( buf, sizeof(buf), "%y%m%d%H%M%SZ", ltm ); +#endif pthread_mutex_unlock( ¤ttime_mutex ); val.bv_val = buf; val.bv_len = strlen( buf ); attr_merge( e, "currenttime", vals ); pthread_mutex_lock( ¤ttime_mutex ); - ltm = localtime( &starttime ); - strftime( buf, sizeof(buf), "%y%m%d%H%M%SZ", ltm ); + ltm = localtime( &starttime ); +#ifdef LDAP_Y2K + strftime( buf, sizeof(buf), "%Y%m%d%H%M%SZ", ltm ); +#else + strftime( buf, sizeof(buf), "%y%m%d%H%M%SZ", ltm ); +#endif pthread_mutex_unlock( ¤ttime_mutex ); val.bv_val = buf; val.bv_len = strlen( buf ); -- 2.39.5