summaryrefslogtreecommitdiffstats
path: root/sources
diff options
context:
space:
mode:
authorOpenGnSys Support Team <soporte-og@soleta.eu>2019-07-29 12:33:41 +0200
committerOpenGnSys Support Team <soporte-og@soleta.eu>2019-07-29 12:37:54 +0200
commit429bd3665ce38cd2257e3c576727c25461f33951 (patch)
tree69ccb516f10e50a0dd020a0a77785eaf46ed3108 /sources
parent8903c6819e3668fb7e654caec5070fea94320cfa (diff)
#891 fix crash in wol command
Irina reports a crash in the wol command on Ubuntu 18.04 and gcc 7.4.0: ==9542== Process terminating with default action of signal 6 (SIGABRT) ==9542== at 0x6C37E97: raise (raise.c:51) ==9542== by 0x6C39800: abort (abort.c:79) ==9542== by 0x6C82896: __libc_message (libc_fatal.c:181) ==9542== by 0x6D2DCD0: __fortify_fail_abort (fortify_fail.c:33) ==9542== by 0x6D2DC91: __stack_chk_fail (stack_chk_fail.c:29) ==9542== by 0x111DB1: WakeUp(int, char*, char*, char*) (ogAdmServer.cpp:1390) ==9542== by 0x11199F: Levanta(char**, char**, int, char*) (ogAdmServer.cpp:1251) ==9542== by 0x118372: og_cmd_wol(json_t*, og_msg_params*) (ogAdmServer.cpp:3580) ==9542== by 0x119B91: og_client_state_process_payload_rest(og_client*) (ogAdmServer.cpp:4030) ==9542== by 0x11A4E9: og_client_read_cb(ev_loop*, ev_io*, int) (ogAdmServer.cpp:4212) ==9542== by 0x5EA1D72: ev_invoke_pending (in /usr/lib/x86_64-linux-gnu/libev.so.4.0.0) ==9542== by 0x5EA53DD: ev_run (in /usr/lib/x86_64-linux-gnu/libev.so.4.0.0) sscanf() returns integers (32-bits) instead of array of 8-bits.
Diffstat (limited to 'sources')
-rw-r--r--sources/ogAdmServer.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/sources/ogAdmServer.cpp b/sources/ogAdmServer.cpp
index 91765af..0efa2a5 100644
--- a/sources/ogAdmServer.cpp
+++ b/sources/ogAdmServer.cpp
@@ -1344,6 +1344,7 @@ enum wol_delivery_type {
//
bool WakeUp(int s, char* iph, char *mac, char *mar)
{
+ unsigned int macaddr[OG_WOL_MACADDR_LEN];
char HDaddress_bin[OG_WOL_MACADDR_LEN];
struct sockaddr_in WakeUpCliente;
struct wol_msg Trama_WakeUp;
@@ -1355,12 +1356,11 @@ bool WakeUp(int s, char* iph, char *mac, char *mar)
Trama_WakeUp.secuencia_FF[i] = 0xFF;
sscanf(mac, "%02x%02x%02x%02x%02x%02x",
- (unsigned int *)&HDaddress_bin[0],
- (unsigned int *)&HDaddress_bin[1],
- (unsigned int *)&HDaddress_bin[2],
- (unsigned int *)&HDaddress_bin[3],
- (unsigned int *)&HDaddress_bin[4],
- (unsigned int *)&HDaddress_bin[5]);
+ &macaddr[0], &macaddr[1], &macaddr[2],
+ &macaddr[3], &macaddr[4], &macaddr[5]);
+
+ for (i = 0; i < 6; i++)
+ HDaddress_bin[i] = (uint8_t)macaddr[i];
for (i = 0; i < 16; i++) // Segunda secuencia de la trama Wake Up , repetir 16 veces su la MAC
memcpy(&Trama_WakeUp.macbin[i][0], &HDaddress_bin, 6);