[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Classpath-inetlib] [PATCH] inetlib bugs
From: |
Székelyi Szabolcs |
Subject: |
[Classpath-inetlib] [PATCH] inetlib bugs |
Date: |
Mon, 23 Jan 2006 22:23:16 +0100 |
User-agent: |
Debian Thunderbird 1.0.7 (X11/20051017) |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
I've discovered some bugs in inetlib.
The first fixes the "mark" bug in CRLFInputStream. The readLine() method
of LineInputStream relies on the underlying input stream ("in") not
being mark()ed before reset()ting it so reset() rewinds the stream to
the last marked position. But CRLFInputStream marks the same stream so
LineInputStream rewinds to the position marked by CRLFInputStream, not
its own mark.
This patch makes CRLFInputStream to use some sort of "faking" technique
instead of marking the stream so LineInputStream works correctly.
The second patch is against MessageInputStream. The bug is here that the
eof flag is not reset when the stream is reset so reading past EOF,
resetting the stream and reading again gives EOF instead of the stream
content right after the mark.
Patches follow.
Bye,
- --
Sze'kelyi Szabolcs
- ------8<------8<------
diff -urN
libgnuinet-java-1.1.1/source/gnu/inet/util/CRLFInputStream.java
libgnuinet-java-1.1.1.new/source/gnu/inet/util/CRLFInputStream.java
- --- libgnuinet-java-1.1.1/source/gnu/inet/util/CRLFInputStream.java
2005-04-06 20:55:41.000000000 +0200
+++ libgnuinet-java-1.1.1.new/source/gnu/inet/util/CRLFInputStream.java
2006-01-23 21:22:14.000000000 +0100
@@ -63,6 +63,9 @@
public static final int LF = 10;
private boolean doReset;
+
+ private boolean fake_read = false;
+ private int fake_c;
/**
* Constructs a CR/LF input stream connected to the specified input
@@ -81,10 +84,15 @@
public int read()
throws IOException
{
+ if(fake_read)
+ {
+ fake_read = false;
+ return fake_c;
+ }
+
int c = in.read();
if (c == CR)
{
- - in.mark(1);
int d = in.read();
if (d == LF)
{
@@ -92,7 +100,8 @@
}
else
{
- - in.reset();
+ fake_read = true;
+ fake_c = d;
}
}
return c;
diff -urN
libgnuinet-java-1.1.1/source/gnu/inet/util/MessageInputStream.java
libgnuinet-java-1.1.1.new/source/gnu/inet/util/MessageInputStream.java
- --- libgnuinet-java-1.1.1/source/gnu/inet/util/MessageInputStream.java
2004-11-25 23:15:05.000000000 +0100
+++
libgnuinet-java-1.1.1.new/source/gnu/inet/util/MessageInputStream.java
2006-01-23 21:22:14.000000000 +0100
@@ -169,6 +169,7 @@
if (c == -1)
{
len = i - off;
+ eof = true;
break;
}
else
@@ -197,6 +198,7 @@
in.reset();
buf1 = markBuf1;
buf2 = markBuf2;
+ eof = false;
}
}
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFD1UlEGJRwVVqzMkMRAhYHAJ9qC+MzE00IYaW7DWZXO962JnWEWgCgn+A0
YTCPjWpRoORep67O58lQ4hY=
=FXOY
-----END PGP SIGNATURE-----
- [Classpath-inetlib] [PATCH] inetlib bugs,
Székelyi Szabolcs <=