aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPlex <thinkplex@riseup.net>2021-10-24 23:49:00 +0200
committerPlex <thinkplex@riseup.net>2021-10-24 23:49:00 +0200
commita5099fdeec6f5e45d88108e28e7c00aa1cf3573c (patch)
tree5298b6ab774831304bab218d58a9ca25f332fb35
parentd937614705989b9e71c366e5fe61751ba0d1a2eb (diff)
forgot to strip most significant bytes from read
-rwxr-xr-xmcpingbin18008 -> 18080 bytes
-rw-r--r--mcping.c16
-rw-r--r--mctypes.c2
-rw-r--r--mctypes.h1
4 files changed, 9 insertions, 10 deletions
diff --git a/mcping b/mcping
index b598bc6..eb5e986 100755
--- a/mcping
+++ b/mcping
Binary files differ
diff --git a/mcping.c b/mcping.c
index 084b481..24e979f 100644
--- a/mcping.c
+++ b/mcping.c
@@ -20,13 +20,13 @@ int main(int argc, char *argv[])
break;
}
}
- varint n;
- n = writeVarInt(atoi(argv[1]));
- // while((*n & 0b10000000) != 0) {
- // printf("%02X ", *n);
- // n++;
- // }
- // printf("%02X\n", *n);
- printf("%d\n", readVarInt(n));
+ varint n, m;
+ m = n = writeVarInt(atoi(argv[1]));
+ while((*n & 0b10000000) != 0) {
+ printf("%02X ", *n);
+ n++;
+ }
+ printf("%02X\n", *n);
+ printf("%d\n", readVarInt(m));
return 0;
}
diff --git a/mctypes.c b/mctypes.c
index 10d083d..6afa230 100644
--- a/mctypes.c
+++ b/mctypes.c
@@ -40,7 +40,7 @@ int readVarInt(varint x)
unsigned int res = 0;
do {
if(offset == 5) exit(EXIT_FAILURE);
- res |= x[offset] << offset*7;
+ res |= (x[offset] & 0b01111111) << offset*7;
offset++;
} while ((x[offset-1] & 0b10000000) != 0);
return (int) res;
diff --git a/mctypes.h b/mctypes.h
index 7dad6db..eb19867 100644
--- a/mctypes.h
+++ b/mctypes.h
@@ -13,6 +13,5 @@ typedef struct {
char *data;
} packet;
-
int readVarInt(varint x);
varint writeVarInt(unsigned int x);