Browse Source

Ticket #47835 - Coverity: 12687..12692

12689 - Unbounded source buffer
Description: To solve "Passing string getenv("TXN_TEST_INDEXES") of
unknown size to slapi_ch_strdup, which expects a string of a particular
size", set upper limit 4KB to the index list length to duplicate.

Reviewed by [email protected] (Thanks, Rich!)

https://fedorahosted.org/389/ticket/47835
Noriko Hosoi 11 years ago
parent
commit
48f2ea020b
1 changed files with 2 additions and 1 deletions
  1. 2 1
      ldap/servers/slapd/back-ldbm/dblayer.c

+ 2 - 1
ldap/servers/slapd/back-ldbm/dblayer.c

@@ -4140,6 +4140,7 @@ 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)
@@ -4152,7 +4153,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_strdup(getenv(TXN_TEST_INDEXES));
+        indexlist_copy = slapi_ch_strndup(getenv(TXN_TEST_INDEXES), TXN_TEST_MAX_INDEX_LIST_LEN);
     } else {
         indexlist_copy = slapi_ch_strdup(indexlist);
     }