summaryrefslogtreecommitdiff
path: root/ot_sync.c
diff options
context:
space:
mode:
authorDirk Engling <erdgeist@erdgeist.org>2026-10-24 05:27:59 +0200
committerDirk Engling <erdgeist@erdgeist.org>2026-10-24 05:27:59 +0200
commit248bf17de8a25c741393b28e75c4e5380947792c (patch)
treecc9e4b8bbe79f015bb9793968b021e10765008a6 /ot_sync.c
parent5fb172a50fc343ef642745b0ecb4b6a44d274b15 (diff)
Use new ranged unsigned int scanner everywhere and squash some bugs along the way
Diffstat (limited to 'ot_sync.c')
-rw-r--r--ot_sync.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/ot_sync.c b/ot_sync.c
index d3d30fa..fa6bb8b 100644
--- a/ot_sync.c
+++ b/ot_sync.c
@@ -12,11 +12,11 @@
12 12
13/* Libowfat */ 13/* Libowfat */
14#include "io.h" 14#include "io.h"
15#include "scan.h"
16 15
17/* Opentracker */ 16/* Opentracker */
18#include "ot_iovec.h" 17#include "ot_iovec.h"
19#include "ot_mutex.h" 18#include "ot_mutex.h"
19#include "ot_scan.h"
20#include "ot_stats.h" 20#include "ot_stats.h"
21#include "ot_sync.h" 21#include "ot_sync.h"
22#include "trackerlogic.h" 22#include "trackerlogic.h"
@@ -30,9 +30,9 @@
30 [..]: ( 20:01234567890abcdefghij16:XXXXYYYY )+ 30 [..]: ( 20:01234567890abcdefghij16:XXXXYYYY )+
31*/ 31*/
32int add_changeset_to_tracker(uint8_t *data, size_t len) { 32int add_changeset_to_tracker(uint8_t *data, size_t len) {
33 ot_hash *hash; 33 ot_hash *hash;
34 uint8_t *end = data + len; 34 uint8_t *end = data + len;
35 unsigned long peer_count; 35 uint64_t peer_count;
36 36
37 /* We do know, that the string is \n terminated, so it can't 37 /* We do know, that the string is \n terminated, so it can't
38 overflow */ 38 overflow */
@@ -50,8 +50,8 @@ int add_changeset_to_tracker(uint8_t *data, size_t len) {
50 hash = (ot_hash *)data; 50 hash = (ot_hash *)data;
51 data += sizeof(ot_hash); 51 data += sizeof(ot_hash);
52 52
53 /* Scan string length indicator */ 53 /* Scan string length indicator, strictly: bencode writes no leading zeros */
54 data += (len = scan_ulong((char *)data, &peer_count)); 54 data += (len = scan_udec_bencode((char *)data, &peer_count, (uint64_t)(end - data)));
55 55
56 /* If no long was scanned, it is not divisible by 8, it is not 56 /* If no long was scanned, it is not divisible by 8, it is not
57 followed by a colon or claims to need to much memory, we fail */ 57 followed by a colon or claims to need to much memory, we fail */