From: "Daniel P. Berrange" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>
Subject: [Qemu-devel] [PATCH PULL v2 10/11] ui: fix return type for VNC I/O functions to be ssize_t
Date: Tue, 15 Sep 2015 11:17:06 +0100 [thread overview]
Message-ID: <1442312227-19153-11-git-send-email-berrange@redhat.com> (raw)
In-Reply-To: <1442312227-19153-1-git-send-email-berrange@redhat.com>
Various VNC server I/O functions return 'long' and then
also pass this to a method accepting 'int'. All these
should be ssize_t to match the signature of read/write
APIs and thus avoid potential for integer truncation /
wraparound.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
ui/vnc.c | 36 ++++++++++++++++++------------------
ui/vnc.h | 6 +++---
2 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/ui/vnc.c b/ui/vnc.c
index caf82f5..19ad088 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -1268,7 +1268,7 @@ void vnc_disconnect_finish(VncState *vs)
g_free(vs);
}
-int vnc_client_io_error(VncState *vs, int ret, int last_errno)
+ssize_t vnc_client_io_error(VncState *vs, ssize_t ret, int last_errno)
{
if (ret == 0 || ret == -1) {
if (ret == -1) {
@@ -1284,7 +1284,7 @@ int vnc_client_io_error(VncState *vs, int ret, int last_errno)
}
}
- VNC_DEBUG("Closing down client sock: ret %d, errno %d\n",
+ VNC_DEBUG("Closing down client sock: ret %zd, errno %d\n",
ret, ret < 0 ? last_errno : 0);
vnc_disconnect_start(vs);
@@ -1301,11 +1301,11 @@ void vnc_client_error(VncState *vs)
}
#ifdef CONFIG_VNC_TLS
-static long vnc_client_write_tls(gnutls_session_t *session,
- const uint8_t *data,
- size_t datalen)
+static ssize_t vnc_client_write_tls(gnutls_session_t *session,
+ const uint8_t *data,
+ size_t datalen)
{
- long ret = gnutls_write(*session, data, datalen);
+ ssize_t ret = gnutls_write(*session, data, datalen);
if (ret < 0) {
if (ret == GNUTLS_E_AGAIN) {
errno = EAGAIN;
@@ -1333,9 +1333,9 @@ static long vnc_client_write_tls(gnutls_session_t *session,
* the requested 'datalen' if the socket would block. Returns
* -1 on error, and disconnects the client socket.
*/
-long vnc_client_write_buf(VncState *vs, const uint8_t *data, size_t datalen)
+ssize_t vnc_client_write_buf(VncState *vs, const uint8_t *data, size_t datalen)
{
- long ret;
+ ssize_t ret;
#ifdef CONFIG_VNC_TLS
if (vs->tls.session) {
ret = vnc_client_write_tls(&vs->tls.session, data, datalen);
@@ -1360,9 +1360,9 @@ long vnc_client_write_buf(VncState *vs, const uint8_t *data, size_t datalen)
* the buffered output data if the socket would block. Returns
* -1 on error, and disconnects the client socket.
*/
-static long vnc_client_write_plain(VncState *vs)
+static ssize_t vnc_client_write_plain(VncState *vs)
{
- long ret;
+ ssize_t ret;
#ifdef CONFIG_VNC_SASL
VNC_DEBUG("Write Plain: Pending output %p size %zd offset %zd. Wait SSF %d\n",
@@ -1436,10 +1436,10 @@ void vnc_read_when(VncState *vs, VncReadEvent *func, size_t expecting)
}
#ifdef CONFIG_VNC_TLS
-static long vnc_client_read_tls(gnutls_session_t *session, uint8_t *data,
- size_t datalen)
+static ssize_t vnc_client_read_tls(gnutls_session_t *session, uint8_t *data,
+ size_t datalen)
{
- long ret = gnutls_read(*session, data, datalen);
+ ssize_t ret = gnutls_read(*session, data, datalen);
if (ret < 0) {
if (ret == GNUTLS_E_AGAIN) {
errno = EAGAIN;
@@ -1467,9 +1467,9 @@ static long vnc_client_read_tls(gnutls_session_t *session, uint8_t *data,
* the requested 'datalen' if the socket would block. Returns
* -1 on error, and disconnects the client socket.
*/
-long vnc_client_read_buf(VncState *vs, uint8_t *data, size_t datalen)
+ssize_t vnc_client_read_buf(VncState *vs, uint8_t *data, size_t datalen)
{
- long ret;
+ ssize_t ret;
#ifdef CONFIG_VNC_TLS
if (vs->tls.session) {
ret = vnc_client_read_tls(&vs->tls.session, data, datalen);
@@ -1492,9 +1492,9 @@ long vnc_client_read_buf(VncState *vs, uint8_t *data, size_t datalen)
* Returns the number of bytes read. Returns -1 on error, and
* disconnects the client socket.
*/
-static long vnc_client_read_plain(VncState *vs)
+static ssize_t vnc_client_read_plain(VncState *vs)
{
- int ret;
+ ssize_t ret;
VNC_DEBUG("Read plain %p size %zd offset %zd\n",
vs->input.buffer, vs->input.capacity, vs->input.offset);
buffer_reserve(&vs->input, 4096);
@@ -1520,7 +1520,7 @@ static void vnc_jobs_bh(void *opaque)
void vnc_client_read(void *opaque)
{
VncState *vs = opaque;
- long ret;
+ ssize_t ret;
#ifdef CONFIG_VNC_SASL
if (vs->sasl.conn && vs->sasl.runSSF)
diff --git a/ui/vnc.h b/ui/vnc.h
index 814d720..194ccf7 100644
--- a/ui/vnc.h
+++ b/ui/vnc.h
@@ -513,8 +513,8 @@ enum {
void vnc_client_read(void *opaque);
void vnc_client_write(void *opaque);
-long vnc_client_read_buf(VncState *vs, uint8_t *data, size_t datalen);
-long vnc_client_write_buf(VncState *vs, const uint8_t *data, size_t datalen);
+ssize_t vnc_client_read_buf(VncState *vs, uint8_t *data, size_t datalen);
+ssize_t vnc_client_write_buf(VncState *vs, const uint8_t *data, size_t datalen);
/* Protocol I/O functions */
void vnc_write(VncState *vs, const void *data, size_t len);
@@ -533,7 +533,7 @@ uint32_t read_u32(uint8_t *data, size_t offset);
/* Protocol stage functions */
void vnc_client_error(VncState *vs);
-int vnc_client_io_error(VncState *vs, int ret, int last_errno);
+ssize_t vnc_client_io_error(VncState *vs, ssize_t ret, int last_errno);
void start_client_init(VncState *vs);
void start_auth_vnc(VncState *vs);
--
2.4.3
next prev parent reply other threads:[~2015-09-15 10:17 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-15 10:16 [Qemu-devel] [PATCH PULL v2 00/11] Extract TLS handling code from VNC server Daniel P. Berrange
2015-09-15 10:16 ` [Qemu-devel] [PATCH PULL v2 01/11] qapi: allow override of default enum prefix naming Daniel P. Berrange
2015-09-15 14:00 ` Eric Blake
2015-09-15 10:16 ` [Qemu-devel] [PATCH PULL v2 02/11] tests: remove repetition in unit test object deps Daniel P. Berrange
2015-09-15 10:16 ` [Qemu-devel] [PATCH PULL v2 03/11] crypto: move crypto objects out of libqemuutil.la Daniel P. Berrange
2015-09-15 10:17 ` [Qemu-devel] [PATCH PULL v2 04/11] qom: allow QOM to be linked into tools binaries Daniel P. Berrange
2015-09-15 10:17 ` [Qemu-devel] [PATCH PULL v2 05/11] crypto: introduce new base module for TLS credentials Daniel P. Berrange
2015-09-15 10:17 ` [Qemu-devel] [PATCH PULL v2 06/11] crypto: introduce new module for TLS anonymous credentials Daniel P. Berrange
2015-09-15 10:17 ` [Qemu-devel] [PATCH PULL v2 07/11] crypto: introduce new module for TLS x509 credentials Daniel P. Berrange
2015-09-15 10:17 ` [Qemu-devel] [PATCH PULL v2 08/11] crypto: add sanity checking of " Daniel P. Berrange
2015-09-15 10:17 ` [Qemu-devel] [PATCH PULL v2 09/11] crypto: introduce new module for handling TLS sessions Daniel P. Berrange
2015-09-15 10:17 ` Daniel P. Berrange [this message]
2015-09-15 10:17 ` [Qemu-devel] [PATCH PULL v2 11/11] ui: convert VNC server to use QCryptoTLSSession Daniel P. Berrange
2015-09-15 11:23 ` [Qemu-devel] [PATCH PULL v2 00/11] Extract TLS handling code from VNC server Peter Maydell
2015-09-15 11:41 ` Daniel P. Berrange
2015-09-15 14:36 ` Daniel P. Berrange
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1442312227-19153-11-git-send-email-berrange@redhat.com \
--to=berrange@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).