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.
This commit is contained in:
René van Dorst
2026-08-26 20:51:27 +02:00
parent 57b820c4e8
commit 683037f410
+6 -4
View File
@@ -310,10 +310,12 @@ __xdata uint8_t *scan_header(__xdata uint8_t *p)
return 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) { while (bytes) {
if (!i) if (!i)
get_random_32(); get_random_32();
@@ -549,7 +551,7 @@ void handle_post(void)
if (is_url_word_x(p, passwd)) { if (is_url_word_x(p, passwd)) {
dbg_string("Password accepted!\n"); dbg_string("Password accepted!\n");
read_reg_timer(&last_session_use); 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; session_id[SESSION_ID_LENGTH] = NUL;
slen = strtox(outbuf, "HTTP/1.1 302 Found\r\nConnection: close\r\nLocation: index.html\r\n" \ slen = strtox(outbuf, "HTTP/1.1 302 Found\r\nConnection: close\r\nLocation: index.html\r\n" \
"Set-Cookie: session="); "Set-Cookie: session=");