Skip to content

Commit dff654c

Browse files
committed
_ct_handle_client_message: Report system errors' descriptions.
Signed-off-by: Aaron M. Ucko <[email protected]>
1 parent bfbeac7 commit dff654c

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/ctlib/ctutil.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,23 @@ _ct_handle_client_message(const TDSCONTEXT * ctx_tds, TDSSOCKET * tds, TDSMESSAG
129129
errmsg.severity = _ct_translate_severity(msg->severity);
130130
strlcpy(errmsg.msgstring, msg->message, sizeof(errmsg.msgstring));
131131
errmsg.msgstringlen = strlen(errmsg.msgstring);
132-
errmsg.osstring[0] = '\0';
133-
errmsg.osstringlen = 0;
132+
133+
if (msg->oserr) {
134+
#ifdef _WIN32
135+
char *osstr = tds_prwsaerror(msg->oserr);
136+
#else
137+
const char *osstr = strerror(msg->oserr);
138+
#endif
139+
errmsg.osstringlen = (CS_INT) strlen(osstr);
140+
strlcpy(errmsg.osstring, osstr, CS_MAX_MSG);
141+
#ifdef _WIN32
142+
tds_prwsaerror_free(osstr);
143+
#endif
144+
} else {
145+
errmsg.osstring[0] = '\0';
146+
errmsg.osstringlen = 0;
147+
}
148+
134149
/* if there is no connection, attempt to call the context handler */
135150
if (!con) {
136151
ctx = (CS_CONTEXT *) ctx_tds->parent;

0 commit comments

Comments
 (0)