From e6460769ab54861e9030d23ba78cc68478e5714c Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Tue, 23 Jul 2002 18:26:33 +0000 Subject: [PATCH] Misc sprintf/snprintf cleanup --- libraries/liblber/debug.c | 5 ++--- libraries/liblber/liblber.dsp | 4 ++++ libraries/libldap/init.c | 6 +++--- libraries/libldap/schema.c | 2 +- libraries/liblunicode/ucdata/ucgendat.c | 14 +++++++------- libraries/liblutil/liblutil.dsp | 4 ---- libraries/liblutil/ntservice.c | 7 ++++--- libraries/liblutil/sasl.c | 2 +- 8 files changed, 22 insertions(+), 22 deletions(-) diff --git a/libraries/liblber/debug.c b/libraries/liblber/debug.c index 4921bd2b30..92b52d67b7 100644 --- a/libraries/liblber/debug.c +++ b/libraries/liblber/debug.c @@ -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; diff --git a/libraries/liblber/liblber.dsp b/libraries/liblber/liblber.dsp index e02e1f3f76..02c82831f9 100644 --- a/libraries/liblber/liblber.dsp +++ b/libraries/liblber/liblber.dsp @@ -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 diff --git a/libraries/libldap/init.c b/libraries/libldap/init.c index e7d0648a1f..96e7b8f3dc 100644 --- a/libraries/libldap/init.c +++ b/libraries/libldap/init.c @@ -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); } diff --git a/libraries/libldap/schema.c b/libraries/libldap/schema.c index 4fd83bc4bd..93a1daf381 100644 --- a/libraries/libldap/schema.c +++ b/libraries/libldap/schema.c @@ -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); diff --git a/libraries/liblunicode/ucdata/ucgendat.c b/libraries/liblunicode/ucdata/ucgendat.c index 2daee8a4c3..7629707a44 100644 --- a/libraries/liblunicode/ucdata/ucgendat.c +++ b/libraries/liblunicode/ucdata/ucgendat.c @@ -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; diff --git a/libraries/liblutil/liblutil.dsp b/libraries/liblutil/liblutil.dsp index a17939d6f3..436a6981bf 100644 --- a/libraries/liblutil/liblutil.dsp +++ b/libraries/liblutil/liblutil.dsp @@ -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 diff --git a/libraries/liblutil/ntservice.c b/libraries/liblutil/ntservice.c index 4d6504211c..9bd27b7065 100644 --- a/libraries/liblutil/ntservice.c +++ b/libraries/liblutil/ntservice.c @@ -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 ) { diff --git a/libraries/liblutil/sasl.c b/libraries/liblutil/sasl.c index 3f330ab1dd..a1308a8018 100644 --- a/libraries/liblutil/sasl.c +++ b/libraries/liblutil/sasl.c @@ -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 ) { -- 2.39.5