Import ITS#2007,#2009 fixes from HEAD (snprintf, O_EXCL)

This commit is contained in:
Howard Chu 2002-08-26 08:48:40 +00:00
parent bf19e07a63
commit 07dd4d39f8

View File

@ -52,13 +52,13 @@ write_reject(
int rc;
ldap_pvt_thread_mutex_lock( &sglob->rej_mutex );
sprintf( rejfile, "%s/%s:%d.rej", sglob->slurpd_rdir,
ri->ri_hostname, ri->ri_port );
snprintf( rejfile, sizeof(rejfile), "%s" LDAP_DIRSEP "%s:%d.rej",
sglob->slurpd_rdir, ri->ri_hostname, ri->ri_port );
if ( access( rejfile, F_OK ) < 0 ) {
/* Doesn't exist - try to create */
int rjfd;
if (( rjfd = open( rejfile, O_RDWR | O_APPEND | O_CREAT,
if (( rjfd = open( rejfile, O_RDWR | O_APPEND | O_CREAT | O_EXCL,
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP )) < 0 ) {
Debug( LDAP_DEBUG_ANY,
"Error: write_reject: Cannot create \"%s\": %s\n",