summaryrefslogtreecommitdiff
path: root/jni/iodine/src/read.c
diff options
context:
space:
mode:
authorYves Fischer <yvesf-git@xapek.org>2014-08-11 23:26:36 +0200
committerYves Fischer <yvesf-git@xapek.org>2014-08-11 23:26:36 +0200
commit5d8801d4687035ae45143f0f3bc3eeaf75dc17ec (patch)
treebf4395fd5938eb1865ba90b6e52e169d727d9404 /jni/iodine/src/read.c
parent1251ce0d7cf2619f9b41637dcb88bebb66e54fb3 (diff)
downloadandiodine-5d8801d4687035ae45143f0f3bc3eeaf75dc17ec.tar.gz
andiodine-5d8801d4687035ae45143f0f3bc3eeaf75dc17ec.zip
Upgrade code to iodine 0.7.0 and improve logging
Diffstat (limited to 'jni/iodine/src/read.c')
-rw-r--r--jni/iodine/src/read.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/jni/iodine/src/read.c b/jni/iodine/src/read.c
index ff40382..a2dcd96 100644
--- a/jni/iodine/src/read.c
+++ b/jni/iodine/src/read.c
@@ -1,5 +1,6 @@
/*
- * Copyright (c) 2006-2009 Bjorn Andersson <flex@kryo.se>, Erik Ekman <yarrick@kryo.se>
+ * Copyright (c) 2006-2014 Erik Ekman <yarrick@kryo.se>,
+ * 2006-2009 Bjorn Andersson <flex@kryo.se>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -60,7 +61,7 @@ readname_loop(char *packet, int packetlen, char **src, char *dst, size_t length,
c--;
}
-
+
if (len >= length - 1) {
break; /* We used up all space */
}
@@ -84,15 +85,15 @@ readname(char *packet, int packetlen, char **src, char *dst, size_t length)
}
int
-readshort(char *packet, char **src, short *dst)
+readshort(char *packet, char **src, unsigned short *dst)
{
unsigned char *p;
p = (unsigned char *) *src;
*dst = (p[0] << 8) | p[1];
- (*src) += sizeof(short);
- return sizeof(short);
+ (*src) += sizeof(unsigned short);
+ return sizeof(unsigned short);
}
int
@@ -103,8 +104,8 @@ readlong(char *packet, char **src, uint32_t *dst)
p = (unsigned char *) *src;
- *dst = ((uint32_t)p[0] << 24)
- | ((uint32_t)p[1] << 16)
+ *dst = ((uint32_t)p[0] << 24)
+ | ((uint32_t)p[1] << 16)
| ((uint32_t)p[2] << 8)
| ((uint32_t)p[3]);
@@ -115,9 +116,6 @@ readlong(char *packet, char **src, uint32_t *dst)
int
readdata(char *packet, char **src, char *dst, size_t len)
{
- if (len < 0)
- return 0;
-
memcpy(dst, *src, len);
(*src) += len;
@@ -165,7 +163,7 @@ putname(char **buf, size_t buflen, const char *host)
h = strdup(host);
left = buflen;
p = *buf;
-
+
word = strtok(h, ".");
while(word) {
if (strlen(word) > 63 || strlen(word) > left) {
@@ -232,11 +230,8 @@ putlong(char **dst, uint32_t value)
int
putdata(char **dst, char *data, size_t len)
{
- if (len < 0)
- return 0;
-
memcpy(*dst, data, len);
-
+
(*dst) += len;
return len;
}