From b4e1ea15f3081a065318f5ee99336494c8765bca Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Wed, 25 Sep 2002 04:34:33 +0000 Subject: [PATCH] benign buffer overflow fix (ITS#1964) --- servers/slapd/at.c | 1 - servers/slapd/lock.c | 3 ++- servers/slurpd/lock.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/servers/slapd/at.c b/servers/slapd/at.c index 238b91f684..5b59674b5e 100644 --- a/servers/slapd/at.c +++ b/servers/slapd/at.c @@ -338,7 +338,6 @@ at_add( ldap_memfree( at->at_syntax_oid ); at->at_syntax_oid = oid; } - } if ( at->at_names && at->at_names[0] ) { diff --git a/servers/slapd/lock.c b/servers/slapd/lock.c index fb5c5bb715..79017f23a0 100644 --- a/servers/slapd/lock.c +++ b/servers/slapd/lock.c @@ -28,7 +28,8 @@ lock_fopen( const char *fname, const char *type, FILE **lfp ) char buf[MAXPATHLEN]; /* open the lock file */ - strcpy(lutil_strcopy( buf, fname ), ".lock" ); + snprintf( buf, sizeof buf, "%s.lock", fname ); + if ( (*lfp = fopen( buf, "w" )) == NULL ) { #ifdef NEW_LOGGING LDAP_LOG( OPERATION, ERR, diff --git a/servers/slurpd/lock.c b/servers/slurpd/lock.c index ce6fffb031..5b707942e6 100644 --- a/servers/slurpd/lock.c +++ b/servers/slurpd/lock.c @@ -47,8 +47,8 @@ lock_fopen( char buf[MAXPATHLEN]; /* open the lock file */ - strcpy( buf, fname ); - strcat( buf, ".lock" ); + snprintf( buf, sizeof buf, "%s.lock", fname ); + if ( (*lfp = fopen( buf, "w" )) == NULL ) { #ifdef NEW_LOGGING LDAP_LOG ( SLURPD, ERR, "lock_fopen: " -- 2.39.5