summaryrefslogtreecommitdiff
path: root/opentracker.c
diff options
context:
space:
mode:
authorDirk Engling <erdgeist@erdgeist.org>2026-10-24 02:04:33 +0200
committerDirk Engling <erdgeist@erdgeist.org>2026-10-24 02:04:33 +0200
commit168285b4569f862443419a2bffe221e1a8ab8150 (patch)
tree27ef578cd4af2e6860bcbc9c0dcb7af16d80b4ec /opentracker.c
parent0eb6054309f23b3cec7cb799485b859fcf61f794 (diff)
Replace all manual hex conversion with the new helper
Diffstat (limited to 'opentracker.c')
-rw-r--r--opentracker.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/opentracker.c b/opentracker.c
index 4d44950..f218589 100644
--- a/opentracker.c
+++ b/opentracker.c
@@ -28,6 +28,7 @@
28 28
29/* Opentracker */ 29/* Opentracker */
30#include "ot_accesslist.h" 30#include "ot_accesslist.h"
31#include "ot_hex.h"
31#include "ot_http.h" 32#include "ot_http.h"
32#include "ot_livesync.h" 33#include "ot_livesync.h"
33#include "ot_mutex.h" 34#include "ot_mutex.h"
@@ -646,16 +647,10 @@ void load_state(const char *const state_filename) {
646 /* We do ignore anything that is not of the form "^[:xdigit:]:\d+:\d+" */ 647 /* We do ignore anything that is not of the form "^[:xdigit:]:\d+:\d+" */
647 while (fgets(inbuf, sizeof(inbuf), state_filehandle)) { 648 while (fgets(inbuf, sizeof(inbuf), state_filehandle)) {
648 size_t i; 649 size_t i;
649 for (i = 0; i < sizeof(ot_hash); ++i) {
650 int eger = 16 * scan_fromhex(inbuf[2 * i]) + scan_fromhex(inbuf[1 + 2 * i]);
651 if (eger < 0)
652 continue;
653 infohash[i] = eger;
654 }
655 650
656 if (i != sizeof(ot_hash)) 651 if (!hex_tohash(infohash, inbuf))
657 continue; 652 continue;
658 i *= 2; 653 i = 2 * sizeof(ot_hash);
659 654
660 if (inbuf[i++] != ':' || !(consumed = scan_ulonglong(inbuf + i, &base))) 655 if (inbuf[i++] != ':' || !(consumed = scan_ulonglong(inbuf + i, &base)))
661 continue; 656 continue;