diff options
author | David Schleef <ds@schleef.org> | 2005-03-26 01:24:38 +0000 |
---|---|---|
committer | David Schleef <ds@schleef.org> | 2005-03-26 01:24:38 +0000 |
commit | a587eb0e3849a4937889cb14bdd14f677ad66c59 (patch) | |
tree | e9cbc444d30eef087d0d84833825a67ae6ea59ed /gst/librfb/rfbbytestream.c | |
parent | 808f0f53fe27fc32b5a40f34f635b1d9c6047ac8 (diff) | |
download | gst-plugins-bad-a587eb0e3849a4937889cb14bdd14f677ad66c59.tar.gz gst-plugins-bad-a587eb0e3849a4937889cb14bdd14f677ad66c59.tar.bz2 gst-plugins-bad-a587eb0e3849a4937889cb14bdd14f677ad66c59.zip |
gst/librfb/gstrfbsrc.c: Check return values to avoid segfaults.
Original commit message from CVS:
* gst/librfb/gstrfbsrc.c: (gst_rfbsrc_get): Check return values
to avoid segfaults.
* gst/librfb/rfbbytestream.c: (rfb_bytestream_get),
(rfb_bytestream_check), (rfb_bytestream_copy_nocheck),
(rfb_bytestream_read), (rfb_bytestream_peek):
* gst/librfb/rfbbytestream.h:
* gst/librfb/rfbdecoder.c: (rfb_socket_get_buffer),
(rfb_socket_send_buffer), (rfb_decoder_iterate),
(rfb_decoder_state_wait_for_protocol_version),
(rfb_decoder_state_wait_for_security),
(rfb_decoder_state_wait_for_server_initialisation),
(rfb_decoder_state_normal), (rfb_decoder_state_framebuffer_update):
Diffstat (limited to 'gst/librfb/rfbbytestream.c')
-rw-r--r-- | gst/librfb/rfbbytestream.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/gst/librfb/rfbbytestream.c b/gst/librfb/rfbbytestream.c index bcdc1b08..729851b0 100644 --- a/gst/librfb/rfbbytestream.c +++ b/gst/librfb/rfbbytestream.c @@ -2,6 +2,9 @@ #include <rfbbytestream.h> #include <string.h> +#include <gst/gst.h> + + RfbBytestream * rfb_bytestream_new (void) { @@ -16,12 +19,14 @@ rfb_bytestream_get (RfbBytestream * bs, int len) buffer = bs->get_buffer (len, bs->user_data); if (buffer) { - g_print ("got buffer (%d bytes)\n", buffer->length); + GST_DEBUG ("got buffer (%d bytes)", buffer->length); bs->buffer_list = g_list_append (bs->buffer_list, buffer); bs->length += buffer->length; return len; + } else { + bs->disconnected = TRUE; } return 0; @@ -32,6 +37,8 @@ rfb_bytestream_check (RfbBytestream * bs, int len) { while (bs->length < len) { rfb_bytestream_get (bs, len - bs->length); + if (bs->disconnected) + return FALSE; } return TRUE; } @@ -50,7 +57,7 @@ rfb_bytestream_copy_nocheck (RfbBytestream * bs, RfbBuffer * buffer, int len) for (item = bs->buffer_list; item; item = g_list_next (item)) { frombuf = (RfbBuffer *) item->data; n = MIN (len, frombuf->length - first_offset); - g_print ("copying %d bytes from %p\n", n, frombuf); + GST_DEBUG ("copying %d bytes from %p", n, frombuf); memcpy (buffer->data + offset, frombuf->data + first_offset, n); first_offset = 0; len -= n; @@ -67,8 +74,14 @@ int rfb_bytestream_read (RfbBytestream * bs, RfbBuffer ** buffer, int len) { RfbBuffer *buf; + int ret; - rfb_bytestream_check (bs, len); + if (bs->disconnected) + return 0; + + ret = rfb_bytestream_check (bs, len); + if (!ret) + return 0; buf = rfb_buffer_new_and_alloc (len); rfb_bytestream_copy_nocheck (bs, buf, len); @@ -84,6 +97,9 @@ rfb_bytestream_peek (RfbBytestream * bs, RfbBuffer ** buffer, int len) { RfbBuffer *buf; + if (bs->disconnected) + return 0; + rfb_bytestream_check (bs, len); buf = rfb_buffer_new_and_alloc (len); |