Răsfoiți Sursa

Bug 630091 - (cov#15514) Initialize DBT in entryrdn_get_parent()

In entryrdn_get_parent(), there is a DBT structure that we can use
without initializing.  If we goto the bail label, we try to free
data.data, but data was never initialized.  We should clear the
memory used by data in the beginning of the function before we have
an opportunity to goto bail.
Nathan Kinder 15 ani în urmă
părinte
comite
96cf8e3d42
1 a modificat fișierele cu 3 adăugiri și 1 ștergeri
  1. 3 1
      ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c

+ 3 - 1
ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c

@@ -1189,6 +1189,9 @@ entryrdn_get_parent(backend *be,
     slapi_log_error(SLAPI_LOG_TRACE, ENTRYRDN_TAG,
                                      "--> entryrdn_get_parent\n");
 
+    /* Initialize data */
+    memset(&data, 0, sizeof(data));
+
     if (NULL == be || NULL == rdn || 0 == id || NULL == prdn || NULL == pid) {
         slapi_log_error(SLAPI_LOG_FATAL, ENTRYRDN_TAG,
                     "entryrdn_get_parent: Param error: Empty %s\n",
@@ -1232,7 +1235,6 @@ entryrdn_get_parent(backend *be,
         slapi_ch_free_string(&orignrdn);
     }
 
-    memset(&data, 0, sizeof(data));
     data.flags = DB_DBT_MALLOC;
 
     /* Setting up a key for the node to get its parent */