[PATCH 1/2] unsign char in message parsing

Alexandre Oliva lxoliva en fsfla.org
Lun Mar 10 04:31:15 UTC 2014


Cast to unsigned any chars read from the buffer while computing lengths
during rnet message parsing.

Remove unused variable while at that.
---
 rnet_message.c |    7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/rnet_message.c b/rnet_message.c
index f47d78c..83a762b 100644
--- a/rnet_message.c
+++ b/rnet_message.c
@@ -151,11 +151,10 @@ int rnet_message_parse(struct rnet_message *msg, char *skey,
 	int b;
 	char *key;
 	int klen;
-	char *kcopy;
 	/* skip first byte */
 	i++;
 	while (i < len) {
-		j = buffer[i];
+		j = (unsigned char)buffer[i];
 		b = j & 0x80;
 		if (b)
 			;
@@ -164,10 +163,10 @@ int rnet_message_parse(struct rnet_message *msg, char *skey,
 		key = buffer + i;
 		klen = j;
 		i += j;
-		j = buffer[i];
+		j = (unsigned char)buffer[i];
 		i++;
 		if (b)
-			j = j << 8 | buffer[i++];
+			j = j << 8 | (unsigned char)buffer[i++];
 		*value = buffer + i;
 		*vlen = j;
 		i += j;



Más información sobre la lista de distribución Softwares-impostos