changeset 874:57268f4aaa94

8/4byte integer type miss-matches On some architectures (e.g. x86_64) ssize_t and long are 8 bytes wide whereas int is only 4 bytes wide. This can cause at best unexpected negative or truncated values and at worse stack corruption. Thanks to Sergio Gelato for pointing this out. Cc: Sergio Gelato <Sergio.Gelato@astro.su.se> Signed-off-by: Simon Horman <horms@verge.net.au>
author Simon Horman <horms@verge.net.au>
date Mon, 27 Sep 2010 23:17:25 +0900
parents 93c6f460a6e7
children 06e0c2cdb64f
files perdition/db/odbc/perditiondb_odbc.c perdition/io.c perdition/perdition.c
diffstat 3 files changed, 7 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/perdition/db/odbc/perditiondb_odbc.c	Mon Sep 13 17:34:39 2010 +0900
+++ b/perdition/db/odbc/perditiondb_odbc.c	Mon Sep 27 23:17:25 2010 +0900
@@ -214,7 +214,7 @@
 		char **str_return, size_t * len_return)
 {
 	SQLINTEGER rc;
-	SQLINTEGER rc2;
+	SQLLEN rc2;
 	int status = -1;
 	SQLHENV env;
 	SQLHDBC hdbc;
--- a/perdition/io.c	Mon Sep 13 17:34:39 2010 +0900
+++ b/perdition/io.c	Mon Sep 27 23:17:25 2010 +0900
@@ -655,7 +655,7 @@
  *         0 otherwise (one of io_a or io_b closes gracefully)
  **********************************************************************/
 
-static int __io_pipe_read(int fd, void *buf, size_t count, void *data){
+static ssize_t __io_pipe_read(int fd, void *buf, size_t count, void *data){
   io_t *io;
   io_select_t *s;
   ssize_t bytes;
@@ -693,7 +693,9 @@
 }
          
 
-static int __io_pipe_write(int fd, const void *buf, size_t count, void *data){
+static ssize_t
+__io_pipe_write(int fd, const void *buf, size_t count, void *data)
+{
   io_t *io;
   io_select_t *s;
 
--- a/perdition/perdition.c	Mon Sep 13 17:34:39 2010 +0900
+++ b/perdition/perdition.c	Mon Sep 27 23:17:25 2010 +0900
@@ -309,14 +309,14 @@
 }
 
 static void perdition_log_close(const char *from_to_host_str,
-				struct auth *auth, int received, int sent)
+				struct auth *auth, size_t received, size_t sent)
 {
 	struct quoted_str authorisation_id = quote_str(auth->authorisation_id);
 
 	VANESSA_LOGGER_ERR_UNSAFE("Closing session:%s "
 				  "authorisation_id=%s%s%s "
 				  "authentication_id=\"%s\" "
-				  "received=%d sent=%d",
+				  "received=%zu sent=%zu",
 				  from_to_host_str,
 				  authorisation_id.quote,
 				  authorisation_id.str,