ldap/servers/slapd/back-ldbm/dblayer.c | 3 --
ldap/servers/slapd/ch_malloc.c | 37 ---------------------------------
ldap/servers/slapd/localhost.c | 3 --
ldap/servers/slapd/main.c | 13 +----------
ldap/servers/slapd/slapi-plugin.h | 1
ldap/servers/slapd/task.c | 10 +++-----
ldap/servers/slapd/tools/dbscan.c | 14 ++++--------
ldap/servers/snmp/main.c | 7 +-----
8 files changed, 15 insertions(+), 73 deletions(-)
New commits:
commit 3a66ec7ca61ee273eb016fe234a3da8202e58e83
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Wed Jul 9 16:08:21 2014 -0700
Revert "Ticket #47835 - Coverity: 12687..12692"
This reverts commit 43c6ff2e7801ff6bbc03961b3161dd60aebf707a.
diff --git a/ldap/servers/slapd/tools/dbscan.c b/ldap/servers/slapd/tools/dbscan.c
index bbfcd0e..023fade 100644
--- a/ldap/servers/slapd/tools/dbscan.c
+++ b/ldap/servers/slapd/tools/dbscan.c
@@ -1077,17 +1077,16 @@ is_changelog(char *filename)
static void usage(char *argv0)
{
- long arg_max = sysconf(_SC_ARG_MAX);
- char *copy = strndup(argv0, arg_max);
+ char *copy = strdup(argv0);
char *p0 = NULL, *p1 = NULL;
- if (copy && (strlen(copy) < arg_max)) {
+ if (NULL != copy) {
/* the full path is not needed in the usages */
- p0 = strrchr(copy, '/');
- if (p0) {
+ p0 = strrchr(argv0, '/');
+ if (NULL != p0) {
*p0 = '\0';
p0++;
} else {
- p0 = copy;
+ p0 = argv0;
}
p1 = strrchr(p0, '-'); /* get rid of -bin from the usage */
if (NULL != p1) {
@@ -1125,9 +1124,6 @@ static void usage(char *argv0)
printf(" # display summary of objectclass.db4\n");
printf(" %s -f objectclass.db4\n", p0);
printf("\n");
- if (copy) {
- free(copy);
- }
exit(1);
}
commit dc4527b6f6ebe7a2c42eb57942af535c31c5cd59
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Wed Jul 9 16:08:11 2014 -0700
Revert "Ticket #47835 - Coverity: 12687..12692"
This reverts commit 0a546bcb3d4625d6db1dcbb342922b4ddb3bee37.
diff --git a/ldap/servers/slapd/main.c b/ldap/servers/slapd/main.c
index 1726e67..d577514 100644
--- a/ldap/servers/slapd/main.c
+++ b/ldap/servers/slapd/main.c
@@ -650,8 +650,6 @@ main( int argc, char **argv)
int return_value = 0;
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
daemon_ports_t ports_info = {0};
- long arg_max = 0;
-
#ifndef __LP64__
#if defined(__hpux) && !defined(__ia64)
/* for static constructors */
@@ -724,16 +722,9 @@ main( int argc, char **argv)
#endif /* _WIN32 */
if ( (myname = strrchr( argv[0], '/' )) == NULL ) {
- arg_max = sysconf(_SC_ARG_MAX);
- myname = slapi_ch_strndup( argv[0], arg_max );
+ myname = slapi_ch_strdup( argv[0] );
} else {
- myname = slapi_ch_strndup( myname + 1, arg_max );
- }
- if (strlen(myname) > arg_max) {
- LDAPDebug(LDAP_DEBUG_ANY,
- "proc name \"%s\" is longer than the allowed max size:
%dB\n",
- myname, arg_max, 0);
- exit(1);
+ myname = slapi_ch_strdup( myname + 1 );
}
#if defined( XP_WIN32 )
commit f5014300dcdf46d9e432e1a8cee640595b862d6f
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Wed Jul 9 16:07:59 2014 -0700
Revert "Ticket #47835 - Coverity: 12687..12692"
This reverts commit 48f2ea020bca3ee750885a6e5f423fae5e3606ca.
diff --git a/ldap/servers/slapd/back-ldbm/dblayer.c
b/ldap/servers/slapd/back-ldbm/dblayer.c
index 9e6c072..0fda6d3 100644
--- a/ldap/servers/slapd/back-ldbm/dblayer.c
+++ b/ldap/servers/slapd/back-ldbm/dblayer.c
@@ -4140,7 +4140,6 @@ print_ttilist(txn_test_iter **ttilist, size_t tticnt)
}
#define TXN_TEST_IDX_OK_IF_NULL "nscpEntryDN"
-#define TXN_TEST_MAX_INDEX_LIST_LEN 4096
static void
txn_test_init_cfg(txn_test_cfg *cfg)
@@ -4153,7 +4152,7 @@ txn_test_init_cfg(txn_test_cfg *cfg)
cfg->flags = getenv(TXN_TEST_USE_RMW) ? DB_RMW : 0;
cfg->use_txn = getenv(TXN_TEST_USE_TXN) ? 1 : 0;
if (getenv(TXN_TEST_INDEXES)) {
- indexlist_copy = slapi_ch_strndup(getenv(TXN_TEST_INDEXES),
TXN_TEST_MAX_INDEX_LIST_LEN);
+ indexlist_copy = slapi_ch_strdup(getenv(TXN_TEST_INDEXES));
} else {
indexlist_copy = slapi_ch_strdup(indexlist);
}
commit 50654969bcfeb0aa379c10ceda3cfd72993a527c
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Wed Jul 9 16:07:48 2014 -0700
Revert "Ticket #47835 - Coverity: 12687..12692"
This reverts commit 162604a620ba75f2a5eed3095930a2aaa823a645.
diff --git a/ldap/servers/slapd/ch_malloc.c b/ldap/servers/slapd/ch_malloc.c
index 46aecc0..b2afbe0 100644
--- a/ldap/servers/slapd/ch_malloc.c
+++ b/ldap/servers/slapd/ch_malloc.c
@@ -301,43 +301,6 @@ slapi_ch_strdup ( const char* s1)
#endif
return newmem;
}
-
-char*
-slapi_ch_strndup ( const char* s1, size_t n)
-{
- char* newmem;
-
- /* strdup pukes on NULL strings...bail out now */
- if ((NULL == s1) || (0 == n)) {
- return NULL;
- }
- newmem = strndup (s1, n);
- if (newmem == NULL) {
- int oserr = errno;
- oom_occurred();
-
- slapi_log_error( SLAPI_LOG_FATAL, SLAPD_MODULE,
- "strdup of %lu characters failed; OS error %d (%s)%s\n",
- (unsigned long)n, oserr, slapd_system_strerror( oserr ),
- oom_advice );
- exit (1);
- }
- if(!counters_created)
- {
- create_counters();
- counters_created= 1;
- }
- PR_INCREMENT_COUNTER(slapi_ch_counter_strdup);
- PR_INCREMENT_COUNTER(slapi_ch_counter_created);
- PR_INCREMENT_COUNTER(slapi_ch_counter_exist);
-#if defined(_WIN32) && defined(DEBUG)
- if(recording)
- {
- add_memory_record(newmem,strlen(s1)+1);
- }
-#endif
- return newmem;
-}
#endif /* !MEMPOOL_EXPERIMENTAL */
struct berval*
diff --git a/ldap/servers/slapd/localhost.c b/ldap/servers/slapd/localhost.c
index fc7de23..c946e8d 100644
--- a/ldap/servers/slapd/localhost.c
+++ b/ldap/servers/slapd/localhost.c
@@ -119,9 +119,8 @@ find_localhost_DNS()
return NULL;
}
if (strchr (hp->h_name, '.') != NULL) {
- long host_name_max = sysconf(_SC_HOST_NAME_MAX);
LDAPDebug (LDAP_DEBUG_CONFIG, "h_name == %s\n", hp->h_name, 0, 0);
- return slapi_ch_strndup (hp->h_name, host_name_max);
+ return slapi_ch_strdup (hp->h_name);
} else if (hp->h_aliases != NULL) {
for (alias = hp->h_aliases; *alias != NULL; ++alias) {
if (strchr (*alias, '.') != NULL &&
diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h
index 126200c..b83b08a 100644
--- a/ldap/servers/slapd/slapi-plugin.h
+++ b/ldap/servers/slapd/slapi-plugin.h
@@ -5799,7 +5799,6 @@ char * slapi_ch_malloc( unsigned long size );
char * slapi_ch_realloc( char *block, unsigned long size );
char * slapi_ch_calloc( unsigned long nelem, unsigned long size );
char * slapi_ch_strdup( const char *s );
-char * slapi_ch_strndup( const char *s, size_t size );
void slapi_ch_free( void **ptr );
void slapi_ch_free_string( char **s );
struct berval* slapi_ch_bvdup(const struct berval*);
commit cef82090cc3ece1a72c2ec1b62205b1f68b1074f
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Wed Jul 9 16:07:34 2014 -0700
Revert "Ticket #47835 - Coverity: 12687..12692"
This reverts commit f25c7f1f988783d620171f7b648f946dc6704c81.
diff --git a/ldap/servers/snmp/main.c b/ldap/servers/snmp/main.c
index fd06dd4..0373877 100644
--- a/ldap/servers/snmp/main.c
+++ b/ldap/servers/snmp/main.c
@@ -75,7 +75,6 @@ main (int argc, char *argv[]) {
struct stat logdir_s;
pid_t child_pid;
FILE *pid_fp;
- long arg_max = 0;
/* Load options */
while ((--argc > 0) && ((*++argv)[0] == '-')) {
@@ -91,13 +90,11 @@ main (int argc, char *argv[]) {
}
}
- if ((argc != 1) || (NULL == *argv)) {
+ if (argc != 1)
exit_usage();
- }
/* load config file */
- arg_max = sysconf(_SC_ARG_MAX);
- if ((config_file = strndup(*argv, arg_max)) == NULL) {
+ if ((config_file = strdup(*argv)) == NULL) {
printf("ldap-agent: Memory error loading config file\n");
exit(1);
}
commit 8247976f25c22799a31be08074cc150e07f5dcce
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Wed Jul 9 16:07:09 2014 -0700
Revert "Ticket #47835 - Coverity: 12687..12692"
This reverts commit 8dc3806d75b6e3d4722047e230db68ac20ab3e69.
diff --git a/ldap/servers/slapd/task.c b/ldap/servers/slapd/task.c
index 1243492..6340db8 100644
--- a/ldap/servers/slapd/task.c
+++ b/ldap/servers/slapd/task.c
@@ -1949,8 +1949,6 @@ task_sysconfig_reload_add(Slapi_PBlock *pb, Slapi_Entry *e,
Slapi_Entry *eAfter,
if ( file != NULL ){
char line[4096];
char *s = NULL;
- /* fgets() reads in at most one less than size characters */
- char *end_of_line = line + sizeof(line) - 1;
if(logchanges){
LDAPDebug(LDAP_DEBUG_ANY, "sysconfig reload task: processing file
(%s)\n",
@@ -1962,8 +1960,8 @@ task_sysconfig_reload_add(Slapi_PBlock *pb, Slapi_Entry *e,
Slapi_Entry *eAfter,
/* skip comments */
continue;
} else {
- char env_value[sizeof(line)];
- char env_var[sizeof(line)];
+ char env_value[4096];
+ char env_var[4096];
int using_setenv = 0;
int value_index = 0;
int start_value = 0;
@@ -1999,7 +1997,7 @@ task_sysconfig_reload_add(Slapi_PBlock *pb, Slapi_Entry *e,
Slapi_Entry *eAfter,
using_setenv = 1;
}
if(strncmp(s, "export ", 7) == 0){
- /* strip off "export " */
+ /* strip off "export " */
s = s + 7;
} else if(strncmp(s, "set ", 4) == 0){
/* strip off "set " */
@@ -2023,7 +2021,7 @@ task_sysconfig_reload_add(Slapi_PBlock *pb, Slapi_Entry *e,
Slapi_Entry *eAfter,
/*
* Start parsing the names and values
*/
- for (; s && (s < end_of_line) && *s; s++){
+ for (; s && *s; s++){
/*
* If using "setenv", allow the first space/tab only, and
start on the env value
*/
commit 4b66c032996c7a313202f315683aa75e83d5f361
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Wed Jul 9 16:06:42 2014 -0700
Revert "Ticket #47835 - Coverity: 12687..12692"
This reverts commit 6e175e3308f04de528254871f6b554fe992dd3df.
diff --git a/ldap/servers/slapd/main.c b/ldap/servers/slapd/main.c
index 6e806d4..1726e67 100644
--- a/ldap/servers/slapd/main.c
+++ b/ldap/servers/slapd/main.c
@@ -723,8 +723,8 @@ main( int argc, char **argv)
#endif /* _WIN32 */
- arg_max = sysconf(_SC_ARG_MAX);
if ( (myname = strrchr( argv[0], '/' )) == NULL ) {
+ arg_max = sysconf(_SC_ARG_MAX);
myname = slapi_ch_strndup( argv[0], arg_max );
} else {
myname = slapi_ch_strndup( myname + 1, arg_max );