caused incorrect data in result array and possibly segmentation
violations when searches terminated due to errors such as timeout,
exceeding search limit, or the remote server going down in the middle
of a search. Also correctly puts error message on top of
traceback stack (instead of randomly in memory per the stale result obj).
A segmentation violation could have manifested later in the program's
life, or perhaps during termination of the interpreter.
LDAPMessage *entryMessage = 0;
char *sortKey;
LDAPMessage *entryMessage = 0;
char *sortKey;
- resultObj = Tcl_GetObjResult (interp);
-
sprintf(filter, filtpatt, value);
fflush(stderr);
if ((msgid = ldap_search (ldap, base, scope, filter, attrs, 0)) == -1) {
sprintf(filter, filtpatt, value);
fflush(stderr);
if ((msgid = ldap_search (ldap, base, scope, filter, attrs, 0)) == -1) {
- Tcl_AppendStringsToObj (resultObj,
+ Tcl_AppendResult (interp,
"LDAP start search error: ",
LDAP_ERR_STRING(ldap),
(char *)NULL);
"LDAP start search error: ",
LDAP_ERR_STRING(ldap),
(char *)NULL);
return tclResult;
}
if (resultCode == -1) {
return tclResult;
}
if (resultCode == -1) {
- Tcl_AppendStringsToObj (resultObj,
+ Tcl_ResetResult (interp);
+ Tcl_AppendResult (interp,
"LDAP result search error: ",
LDAP_ERR_STRING(ldap),
(char *)NULL);
LDAP_SetErrorCode(ldaptcl, -1, interp);
return TCL_ERROR;
}
"LDAP result search error: ",
LDAP_ERR_STRING(ldap),
(char *)NULL);
LDAP_SetErrorCode(ldaptcl, -1, interp);
return TCL_ERROR;
}
- if (resultCode == 0) {
- Tcl_SetErrorCode (interp, "TIMEOUT", (char*) NULL);
- Tcl_SetStringObj (resultObj, "LDAP timeout retrieving results", -1);
- return TCL_ERROR;
- }
- /*
- if (resultCode == LDAP_RES_SEARCH_RESULT ||
- (all && resultCode == LDAP_RES_SEARCH_ENTRY))
- return tclResult;
- */
if ((errorCode = ldap_result2error (ldap, resultMessage, 0))
!= LDAP_SUCCESS) {
if ((errorCode = ldap_result2error (ldap, resultMessage, 0))
!= LDAP_SUCCESS) {
- Tcl_AppendStringsToObj (resultObj,
+ Tcl_ResetResult (interp);
+ Tcl_AppendResult (interp,
"LDAP search error: ",
ldap_err2string(errorCode),
(char *)NULL);
"LDAP search error: ",
ldap_err2string(errorCode),
(char *)NULL);