/pidgin/main: 84fb3f1d401b: Gadu-Gadu: fix some harmless Coverit...

Tomasz Wasilczyk tomkiewicz at cpw.pidgin.im
Tue Jan 29 08:45:16 EST 2013


Changeset: 84fb3f1d401b1bb3cf3fa167ea35bd00bb3218c3
Author:	 Tomasz Wasilczyk <tomkiewicz at cpw.pidgin.im>
Date:	 2013-01-29 14:45 +0100
Branch:	 release-2.x.y
URL: http://hg.pidgin.im/pidgin/main/rev/84fb3f1d401b

Description:

Gadu-Gadu: fix some harmless Coverity issues

diffstat:

 libpurple/protocols/gg/lib/common.c  |  3 ++-
 libpurple/protocols/gg/lib/dcc.c     |  1 +
 libpurple/protocols/gg/lib/dcc7.c    |  5 +++--
 libpurple/protocols/gg/lib/libgadu.c |  2 +-
 4 files changed, 7 insertions(+), 4 deletions(-)

diffs (72 lines):

diff --git a/libpurple/protocols/gg/lib/common.c b/libpurple/protocols/gg/lib/common.c
--- a/libpurple/protocols/gg/lib/common.c
+++ b/libpurple/protocols/gg/lib/common.c
@@ -86,7 +86,7 @@ char *gg_vsaprintf(const char *format, v
 		size = 128;
 		do {
 			size *= 2;
-			if (!(tmp = realloc(buf, size))) {
+			if (!(tmp = realloc(buf, size + 1))) {
 				free(buf);
 				return NULL;
 			}
@@ -276,6 +276,7 @@ int gg_connect(void *addr, int port, int
 		}
 	}
 
+	memset(&sin, 0, sizeof(sin));
 	sin.sin_port = htons(port);
 	sin.sin_family = AF_INET;
 	sin.sin_addr.s_addr = a->s_addr;
diff --git a/libpurple/protocols/gg/lib/dcc.c b/libpurple/protocols/gg/lib/dcc.c
--- a/libpurple/protocols/gg/lib/dcc.c
+++ b/libpurple/protocols/gg/lib/dcc.c
@@ -424,6 +424,7 @@ struct gg_dcc *gg_dcc_socket_create(uin_
 		port = GG_DEFAULT_DCC_PORT;
 
 	while (!bound) {
+		memset(&sin, 0, sizeof(sin));
 		sin.sin_family = AF_INET;
 		sin.sin_addr.s_addr = INADDR_ANY;
 		sin.sin_port = htons(port);
diff --git a/libpurple/protocols/gg/lib/dcc7.c b/libpurple/protocols/gg/lib/dcc7.c
--- a/libpurple/protocols/gg/lib/dcc7.c
+++ b/libpurple/protocols/gg/lib/dcc7.c
@@ -146,7 +146,7 @@ static struct gg_dcc7 *gg_dcc7_session_f
 
 	for (tmp = sess->dcc7_list; tmp; tmp = tmp->next) {
 		if (empty) {
-			if (tmp->peer_uin == uin && !tmp->state == GG_STATE_WAITING_FOR_ACCEPT)
+			if (tmp->peer_uin == uin /*&& tmp->state != GG_STATE_WAITING_FOR_ACCEPT*/)
 				return tmp;
 		} else {
 			if (!memcmp(&tmp->cid, &id, sizeof(id)))
@@ -245,6 +245,7 @@ static int gg_dcc7_listen(struct gg_dcc7
 		return -1;
 	}
 
+	memset(&sin, 0, sizeof(sin));
 	sin.sin_family = AF_INET;
 	sin.sin_addr.s_addr = addr;
 	sin.sin_port = htons(port);
@@ -655,7 +656,7 @@ int gg_dcc7_handle_id(struct gg_session 
 				s.uin_to = gg_fix32(tmp->peer_uin);
 				s.size = gg_fix32(tmp->size);
 
-				strncpy((char*) s.filename, (char*) tmp->filename, GG_DCC7_FILENAME_LEN);
+				memcpy((char*) s.filename, (char*) tmp->filename, GG_DCC7_FILENAME_LEN);
 
 				tmp->state = GG_STATE_WAITING_FOR_ACCEPT;
 				tmp->timeout = GG_DCC7_TIMEOUT_FILE_ACK;
diff --git a/libpurple/protocols/gg/lib/libgadu.c b/libpurple/protocols/gg/lib/libgadu.c
--- a/libpurple/protocols/gg/lib/libgadu.c
+++ b/libpurple/protocols/gg/lib/libgadu.c
@@ -525,7 +525,7 @@ void *gg_recv_packet(struct gg_session *
 		while (sess->header_done < sizeof(h)) {
 			ret = gg_read(sess, (char*) &h + sess->header_done, sizeof(h) - sess->header_done);
 
-			gg_debug_session(sess, GG_DEBUG_MISC, "// gg_recv_packet() header recv(%d,%p,%d) = %d\n", sess->fd, &h + sess->header_done, sizeof(h) - sess->header_done, ret);
+			gg_debug_session(sess, GG_DEBUG_MISC, "// gg_recv_packet() header recv(%d,%p,%d) = %d\n", sess->fd, (char*)&h + sess->header_done, sizeof(h) - sess->header_done, ret);
 
 			if (!ret) {
 				errno = ECONNRESET;



More information about the Commits mailing list