gnome-vfs code freeze break request - http method crasher
- From: Christian Kellner <gicmo xatom net>
- To: "release-team gnome org" <release-team gnome org>
- Cc: "gnome-vfs-list gnome org" <gnome-vfs-list gnome org>
- Subject: gnome-vfs code freeze break request - http method crasher
- Date: Tue, 07 Sep 2004 00:17:16 -0700
Hi!
I fear I have to ask for another code freeze break for the http neon
method. I wouldn't do it but the patch fixes a really bad bug in the
http neon method. The problem with the current code is that it assumes
that ne_read_response_block returns only positiv values or 0. But in
fact it can return -1 on a IO error. In exactly that case calling
ne_end_request () will crash the method. In other words one must not
call ne_end_request if ne_read_response_block returns -1. So the patch
does correct two important things. 1) It changes "n" from
GnomeVFSFileSize to ssize_t so n can be negative. 2) It catches the case
that n == -1 and avoids calling ne_end_request in that case but sets the
results to GNOME_VFS_ERROR_IO (what is exactly what happened then).
I am sorry for the complicated patch but I think this is the cleanest
way to fix it. If you have any other questions feel free to ask.
It also removes the check for bytes_read being NULL because gnome-vfs
will ensure that it inst for us.
Thanks in advance,
Christian
Index: http-neon-method.c
===================================================================
RCS file: /cvs/gnome/gnome-vfs/modules/http-neon-method.c,v
retrieving revision 1.8
diff -u -r1.8 http-neon-method.c
--- http-neon-method.c 27 Aug 2004 10:45:31 -0000 1.8
+++ http-neon-method.c 27 Aug 2004 14:12:40 -0000
@@ -2143,9 +2143,17 @@
if (IS_REDIRECT (status->code) || IS_AUTH_REQ (status->code)) {
/* send the body to /dev/null */
- while (ne_read_response_block (req, dropbuf, sizeof (dropbuf)))
+ while ((res = ne_read_response_block (req, dropbuf, sizeof (dropbuf))) > 0)
/* noop */;
+ if (res < 0) {
+ handle->transfer_state = TRANSFER_ERROR;
+ result = GNOME_VFS_ERROR_IO;
+ handle->last_error = result;
+ ne_request_destroy (req);
+ return result;
+ }
+
res = ne_end_request (req);
ne_request_destroy (req);
req = NULL;
@@ -2388,7 +2396,7 @@
{
GnomeVFSResult result;
HttpFileHandle *handle;
- GnomeVFSFileSize n;
+ ssize_t n;
int res;
_GNOME_VFS_METHOD_PARAM_CHECK (method_handle != NULL);
@@ -2412,30 +2420,30 @@
n = ne_read_response_block (handle->transfer.read, buffer, num_bytes);
- if (bytes_read != NULL)
- *bytes_read = (n > 0 ? n : 0);
-
if (n < 1) {
- res = ne_end_request (handle->transfer.read);
-
+
if (n == 0) {
+ res = ne_end_request (handle->transfer.read);
+
result = GNOME_VFS_ERROR_EOF;
handle->transfer_state = TRANSFER_IDLE;
} else {
+ result = GNOME_VFS_ERROR_IO;
handle->transfer_state = TRANSFER_ERROR;
- result = resolve_result (res, handle->transfer.read);
}
ne_request_destroy (handle->transfer.read);
handle->transfer.read = NULL;
handle->last_error = result;
handle->offset = 0;
+ *bytes_read = 0;
+
return result;
}
-
+ *bytes_read = n;
- handle->offset += num_bytes;
+ handle->offset += *bytes_read;
return result;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]