From 168285b4569f862443419a2bffe221e1a8ab8150 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Sat, 24 Oct 2026 02:04:33 +0200 Subject: Replace all manual hex conversion with the new helper --- opentracker.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'opentracker.c') diff --git a/opentracker.c b/opentracker.c index 4d44950..f218589 100644 --- a/opentracker.c +++ b/opentracker.c @@ -28,6 +28,7 @@ /* Opentracker */ #include "ot_accesslist.h" +#include "ot_hex.h" #include "ot_http.h" #include "ot_livesync.h" #include "ot_mutex.h" @@ -646,16 +647,10 @@ void load_state(const char *const state_filename) { /* We do ignore anything that is not of the form "^[:xdigit:]:\d+:\d+" */ while (fgets(inbuf, sizeof(inbuf), state_filehandle)) { size_t i; - for (i = 0; i < sizeof(ot_hash); ++i) { - int eger = 16 * scan_fromhex(inbuf[2 * i]) + scan_fromhex(inbuf[1 + 2 * i]); - if (eger < 0) - continue; - infohash[i] = eger; - } - if (i != sizeof(ot_hash)) + if (!hex_tohash(infohash, inbuf)) continue; - i *= 2; + i = 2 * sizeof(ot_hash); if (inbuf[i++] != ':' || !(consumed = scan_ulonglong(inbuf + i, &base))) continue; -- cgit v1.3