Commit e6460769 authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

Misc sprintf/snprintf cleanup

parent b6bbc69e
......@@ -106,7 +106,7 @@ int lutil_mnem2level( const char *level )
static int addSubsys( const char *subsys, int level )
{
int i, j, subsys_num;
int subsys_num;
if ( !strcasecmp( subsys, "backend" ) )
{
......@@ -152,8 +152,7 @@ void lutil_log_int(
time_t now;
struct tm *today;
#endif
int i;
char data[4096];
size_t i;
char * t_subsys;
char * tmp;
......
......@@ -179,6 +179,10 @@ SOURCE=.\bprint.c
# End Source File
# Begin Source File
SOURCE=.\debug.c
# End Source File
# Begin Source File
SOURCE=.\decode.c
# End Source File
# Begin Source File
......
......@@ -267,7 +267,7 @@ static void openldap_ldap_init_w_userconf(const char *file)
Debug(LDAP_DEBUG_TRACE, "ldap_init: HOME env is %s\n",
home, 0, 0);
#endif
path = LDAP_MALLOC(strlen(home) + strlen(file) + 3);
path = LDAP_MALLOC(strlen(home) + strlen(file) + sizeof( LDAP_DIRSEP "."));
} else {
#ifdef NEW_LOGGING
LDAP_LOG ( CONFIG, ARGS, "openldap_init_w_userconf: HOME env is NULL\n",
......@@ -282,11 +282,11 @@ static void openldap_ldap_init_w_userconf(const char *file)
/* we assume UNIX path syntax is used... */
/* try ~/file */
sprintf(path, "%s%s%s", home, LDAP_DIRSEP, file);
sprintf(path, "%s" LDAP_DIRSEP "%s", home, file);
openldap_ldap_init_w_conf(path, 1);
/* try ~/.file */
sprintf(path, "%s%s.%s", home, LDAP_DIRSEP, file);
sprintf(path, "%s" LDAP_DIRSEP ".%s", home, file);
openldap_ldap_init_w_conf(path, 1);
}
......
......@@ -281,7 +281,7 @@ print_noidlen(safe_string *ss, char *s, int l)
ret = print_numericoid(ss,s);
if ( l ) {
sprintf(buf,"{%d}",l);
snprintf(buf, sizeof buf, "{%d}",l);
ret = print_literal(ss,buf);
}
return(ret);
......
......@@ -1229,7 +1229,7 @@ write_cdata(char *opath)
/*
* Open the ctype.dat file.
*/
sprintf(path, "%s%sctype.dat", opath, LDAP_DIRSEP);
snprintf(path, sizeof path, "%s%sctype.dat", opath, LDAP_DIRSEP);
if ((out = fopen(path, "wb")) == 0)
return;
......@@ -1300,7 +1300,7 @@ write_cdata(char *opath)
/*
* Open the case.dat file.
*/
sprintf(path, "%s%scase.dat", opath, LDAP_DIRSEP);
snprintf(path, sizeof path, "%s%scase.dat", opath, LDAP_DIRSEP);
if ((out = fopen(path, "wb")) == 0)
return;
......@@ -1355,7 +1355,7 @@ write_cdata(char *opath)
/*
* Open the comp.dat file.
*/
sprintf(path, "%s%scomp.dat", opath, LDAP_DIRSEP);
sprintf(path, sizeof path, "%s%scomp.dat", opath, LDAP_DIRSEP);
if ((out = fopen(path, "wb")) == 0)
return;
......@@ -1393,7 +1393,7 @@ write_cdata(char *opath)
/*
* Open the decomp.dat file.
*/
sprintf(path, "%s%sdecomp.dat", opath, LDAP_DIRSEP);
snprintf(path, sizeof path, "%s%sdecomp.dat", opath, LDAP_DIRSEP);
if ((out = fopen(path, "wb")) == 0)
return;
......@@ -1447,7 +1447,7 @@ write_cdata(char *opath)
/*
* Open the kdecomp.dat file.
*/
sprintf(path, "%s%skdecomp.dat", opath, LDAP_DIRSEP);
snprintf(path, sizeof path, "%s%skdecomp.dat", opath, LDAP_DIRSEP);
if ((out = fopen(path, "wb")) == 0)
return;
......@@ -1507,7 +1507,7 @@ write_cdata(char *opath)
/*
* Open the cmbcl.dat file.
*/
sprintf(path, "%s%scmbcl.dat", opath, LDAP_DIRSEP);
snprintf(path, sizeof path, "%s%scmbcl.dat", opath, LDAP_DIRSEP);
if ((out = fopen(path, "wb")) == 0)
return;
......@@ -1545,7 +1545,7 @@ write_cdata(char *opath)
/*
* Open the num.dat file.
*/
sprintf(path, "%s%snum.dat", opath, LDAP_DIRSEP);
snprintf(path, sizeof path, "%s%snum.dat", opath, LDAP_DIRSEP);
if ((out = fopen(path, "wb")) == 0)
return;
......
......@@ -144,10 +144,6 @@ SOURCE=.\csn.c
# End Source File
# Begin Source File
SOURCE=.\debug.c
# End Source File
# Begin Source File
SOURCE=.\entropy.c
# End Source File
# Begin Source File
......
......@@ -83,7 +83,8 @@ int srv_install(LPCTSTR lpszServiceName, LPCTSTR lpszDisplayName,
CloseServiceHandle(schService);
CloseServiceHandle(schSCManager);
sprintf( regpath, "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\%s",
snprintf( regpath, sizeof regpath,
"SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\%s",
lpszServiceName );
/* Create the registry key for event logging to the Windows NT event log. */
if ( RegCreateKeyEx(HKEY_LOCAL_MACHINE,
......@@ -357,9 +358,9 @@ void *getRegParam( char *svc, char *value )
DWORD valLen = sizeof( vValue );
if ( svc != NULL )
sprintf ( path, "SOFTWARE\\%s", svc );
snprintf ( path, sizeof path, "SOFTWARE\\%s", svc );
else
strcpy (path, "SOFTWARE\\OpenLDAP\\Parameters" );
snprintf ( path, sizeof path, "SOFTWARE\\OpenLDAP\\Parameters" );
if ( RegOpenKeyEx( HKEY_LOCAL_MACHINE, path, 0, KEY_READ, &hkey ) != ERROR_SUCCESS )
{
......
......@@ -126,7 +126,7 @@ static int interaction(
fprintf( stderr, "Default: %s\n", dflt );
}
sprintf( input, "%s: ",
snprintf( input, sizeof input, "%s: ",
interact->prompt ? interact->prompt : "Interact" );
if( noecho ) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment