Skip to content

Commit

Permalink
fixed unregistered bug equivalent to DNET-140
Browse files Browse the repository at this point in the history
  • Loading branch information
rrokytskyy committed May 17, 2008
1 parent e4e1e6f commit 6e30a33
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 6 deletions.
36 changes: 30 additions & 6 deletions src/main/org/firebirdsql/gds/impl/wire/AbstractJavaGDSImpl.java
Expand Up @@ -1638,6 +1638,20 @@ public int iscVaxInteger(byte[] buffer, int pos, int length) {
}
return value;
}

public int iscInteger(byte[] buffer, int pos, int length) {
int value;
int shift;

value = shift = 0;

int i = pos;
while (i < length) {
value = value << 8;
value += (buffer[i++] & 0xff);
}
return value;
}

// -----------------------------------------------
// Blob methods
Expand Down Expand Up @@ -2940,23 +2954,33 @@ public int iscQueueEvents(IscDbHandle dbHandle,
nextOperation(db);

int auxHandle = db.in.readInt();
// garbage
byte[] buffer = db.in.readRawBuffer(8);

int port = iscVaxInteger(db.in.readRawBuffer(2), 0, 2);
int respLen = db.in.readInt();
respLen += respLen % 4;

// sin family
db.in.readRawBuffer(2);
int dummySinFamily = db.in.readShort();
respLen -= 2;

// sin port
int port = db.in.readShort();
respLen -= 2;

// IP address
byte[] ipBytes = db.in.readRawBuffer(4);
respLen -= 4;

StringBuffer ipBuf = new StringBuffer();
for (int i = 3; i >= 0; i--){
for (int i = 0; i < 4; i++){
ipBuf.append((int)(ipBytes[i] & 0xff));
if (i > 0) ipBuf.append(".");
if (i < 4) ipBuf.append(".");
}
String ipAddress = ipBuf.toString();

// Ignore
db.in.readRawBuffer(12);
buffer = db.in.readRawBuffer(respLen);
readStatusVector(db);

db.eventCoordinator =
Expand Down Expand Up @@ -3000,7 +3024,7 @@ public void iscCancelEvents(IscDbHandle dbHandle, EventHandle eventHandle)
throw new GDSException(ISCConstants.isc_bad_db_handle);
}

if (db.eventCoordinator.cancelEvents(handleImp)){
if (db.eventCoordinator != null && db.eventCoordinator.cancelEvents(handleImp)){
synchronized (db){
try {
db.out.writeInt(op_cancel_events);
Expand Down
11 changes: 11 additions & 0 deletions src/main/org/firebirdsql/gds/impl/wire/XdrInputStream.java
Expand Up @@ -186,6 +186,17 @@ public long readLong() throws IOException {
public int readInt() throws IOException {
return (read() << 24) | (read() << 16) | (read() << 8) | (read() << 0);
}

/**
* Read in a <code>short</code>.
*
* @return The <code>short</code> that was read
* @throws IOException if an error occurs while reading from the
* underlying input stream
*/
public int readShort() throws IOException {
return (read() << 8) | (read() << 0);
}

/**
* Read a given amount of data from the underlying input stream. The data
Expand Down

0 comments on commit 6e30a33

Please sign in to comment.