From 683037f41003e076e1e6ce6f888eba2794a4e895 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20van=20Dorst?= Date: Wed, 5 Aug 2026 16:13:09 +0200 Subject: [PATCH] httpd: rename gen_random_bytes to gen_random_hex_chars This reflexs the function better. Moving `byte` arguments to __xdata which saves 1 SRAM byte. --- httpd/httpd.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/httpd/httpd.c b/httpd/httpd.c index 6ff824e..a97bb52 100644 --- a/httpd/httpd.c +++ b/httpd/httpd.c @@ -310,10 +310,12 @@ __xdata uint8_t *scan_header(__xdata uint8_t *p) return p; } - -void gen_random_bytes(__xdata uint8_t *b, register uint8_t bytes) +/* + * Generate random HEX-chars at the buffer location. + */ +void gen_random_hex_chars(__xdata uint8_t * b, __xdata uint8_t bytes) { - __xdata uint8_t i = 0; + uint8_t i = 0; while (bytes) { if (!i) get_random_32(); @@ -549,7 +551,7 @@ void handle_post(void) if (is_url_word_x(p, passwd)) { dbg_string("Password accepted!\n"); read_reg_timer(&last_session_use); - gen_random_bytes(session_id, SESSION_ID_LENGTH); + gen_random_hex_chars(session_id, SESSION_ID_LENGTH); session_id[SESSION_ID_LENGTH] = NUL; slen = strtox(outbuf, "HTTP/1.1 302 Found\r\nConnection: close\r\nLocation: index.html\r\n" \ "Set-Cookie: session=");