mirror of
https://github.com/postgres/postgres.git
synced 2025-06-04 00:02:37 -04:00
The current implementation of BlobInputStream does
not properly handle 8-bit unsigned data as it blindly casts the byte to an int, which java most helpfully promotes to a signed type. This causes problems when you can only return -1 to indicated EOF. The following patch fixes the bug and has been tested locally on image data. Chad David
This commit is contained in:
parent
dbb219b896
commit
e046e1dfab
@ -64,10 +64,18 @@ public class BlobInputStream extends InputStream {
|
||||
}
|
||||
|
||||
// Handle EOF
|
||||
if(bpos>=buffer.length)
|
||||
if(bpos >= buffer.length) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return (int) buffer[bpos++];
|
||||
int ret = (buffer[bpos] & 0x7F);
|
||||
if ((buffer[bpos] &0x80) == 0x80) {
|
||||
ret |= 0x80;
|
||||
}
|
||||
|
||||
bpos++;
|
||||
|
||||
return ret;
|
||||
} catch(SQLException se) {
|
||||
throw new IOException(se.toString());
|
||||
}
|
||||
@ -152,5 +160,4 @@ public class BlobInputStream extends InputStream {
|
||||
public boolean markSupported() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user