Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if TDSCommand counter is null before incrementing. #2368

Merged
merged 3 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -6916,6 +6916,15 @@ final boolean readPacket() throws SQLServerException {

// if messageType is RPC or QUERY, then increment Counter's state
if (tdsChannel.getWriter().checkIfTdsMessageTypeIsBatchOrRPC() && null != command) {
if (logger.isLoggable(Level.FINER)) {
logger.warning(toString() + ": increasing state of counter for TDS Command: " + command.toString());
}

if (null == command.getCounter()) {
Jeffery-Wasty marked this conversation as resolved.
Show resolved Hide resolved
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_NullValue"));
Object[] msgArgs1 = {"TDS command counter"};
throw new SQLServerException(form.format(msgArgs1), null);
}
command.getCounter().increaseCounter(packetLength);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ protected Object[][] getContents() {
{"R_crCommandCannotTimeOut", "Request failed to time out and SQLServerConnection does not exist"},
{"R_InvalidIPAddressPreference", "IP address preference {0} is not valid."},
{"R_UnableLoadAuthDll", "Unable to load authentication DLL {0}"},
{"R_illegalArgumentTrustManager", "Interal error. Peer certificate chain or key exchange algorithem can not be null or empty."},
{"R_illegalArgumentTrustManager", "Internal error. Peer certificate chain or key exchange algorithm can not be null or empty."},
{"R_serverCertExpired", "Server Certificate has expired: {0}: {1}"},
{"R_serverCertNotYetValid", "Server Certificate is not yet valid: {0}: {1}"},
{"R_serverCertError", "Error validating Server Certificate: {0}: \n{1}:\n{2}."},
Expand Down