Skip to content

Commit

Permalink
[core] improve logging on oversized fields in odbc
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Jerris authored and andywolk committed Mar 17, 2021
1 parent 96e1398 commit 7539921
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/switch_odbc.c
Original file line number Diff line number Diff line change
Expand Up @@ -644,25 +644,25 @@ SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_callback_exec_detailed(c
}

if (truncated) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "sql data truncated - %s\n",SqlState);
if (StrLen_or_IndPtr && StrLen_or_IndPtr <= 268435456) {
ColumnSize = StrLen_or_IndPtr + 1;
vals[y] = malloc(ColumnSize);
switch_assert(vals[y]);
memset(vals[y], 0, ColumnSize);
SQLGetData(stmt, x, SQL_C_CHAR, (SQLCHAR *) vals[y], ColumnSize, NULL);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SQLGetData large column [%lu]\n", (unsigned long)ColumnSize);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQLGetData failed");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "sql data truncated - %s\n",SqlState);
vals[y] = NULL;
}
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQLGetData failed");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQLGetData failed\n");
vals[y] = NULL;
}
} else if (rc == SQL_SUCCESS){
vals[y] = strdup((char *)val);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQLGetData failed");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQLGetData failed\n");
vals[y] = NULL;
}
} else {
Expand Down

1 comment on commit 7539921

@andywolk
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.