summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOpenGnSys Support Team <soporte-og@soleta.eu>2021-03-30 13:55:33 +0200
committerOpenGnSys Support Team <soporte-og@soleta.eu>2021-03-30 13:58:31 +0200
commita71cba4df1c0ba98d9db44cff45fcaa111e00430 (patch)
tree6dd4a086d972bb9704968e908c1cbee16baf8992
parent1c2a0cad8b44757b6d1cb3c48527a757748e8978 (diff)
#990 fix crash in wol with malformed IP address
==28831== 1 errors in context 1 of 2: ==28831== Invalid read of size 1 ==28831== at 0x55AC6FD: inet_aton (inet_addr.c:127) ==28831== by 0x10ECCA: WakeUp (ogAdmServer.c:337) ==28831== by 0x10EED6: Levanta (ogAdmServer.c:292) ==28831== by 0x11651E: og_cmd_wol (rest.c:498) ==28831== by 0x11651E: og_client_state_process_payload_rest (rest.c:3970) ==28831== by 0x110CF3: og_client_read_cb (core.c:143) ==28831== by 0x4E41D72: ev_invoke_pending (in /usr/lib/x86_64-linux-gnu/libev.so.4.0.0) ==28831== by 0x4E453DD: ev_run (in /usr/lib/x86_64-linux-gnu/libev.so.4.0.0) ==28831== by 0x10E3E5: ev_loop (ev.h:835) ==28831== by 0x10E3E5: main (main.c:100) ==28831== Address 0x0 is not stack'd, malloc'd or (recently) free'd Use number of matching ip addresses in the database, skip if zero.
-rw-r--r--src/rest.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/rest.c b/src/rest.c
index bedb3d5..81dfa7c 100644
--- a/src/rest.c
+++ b/src/rest.c
@@ -495,8 +495,11 @@ static int og_cmd_wol(json_t *element, struct og_msg_params *params)
dbi_result_free(result);
og_dbi_close(dbi);
+ if (i == 0)
+ return 0;
+
if (!Levanta((char **)params->ips_array, (char **)params->mac_array,
- (char **)params->netmask_array, params->ips_array_len,
+ (char **)params->netmask_array, i,
(char *)params->wol_type))
return -1;