summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandre Oliva <lxoliva@fsfla.org>2014-03-10 01:31:15 -0300
committerThadeu Lima de Souza Cascardo <cascardo@cascardo.info>2014-03-10 08:33:32 -0300
commit27ee677e7f33ec652038c18e3f1e6e3fca6c5cde (patch)
tree81aba71cd2dd0dfa065aba2989518f4aabe46870
parent6829681fd0c77efa1da391637cd4d53e93ed8d65 (diff)
unsign char in message parsing
Cast to unsigned any chars read from the buffer while computing lengths during rnet message parsing. Remove unused variable while at that.
-rw-r--r--rnet_message.c7
1 files 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;