From 1a206566ea2062562ae1fa1569aa9e7ff2e42006 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Tue, 14 Jun 2016 11:40:25 +0200 Subject: [PATCH] Fix netaddr deserialization for AF_UNSPEC and AF_LOCAL. --- netwerk/ipc/NeckoMessageUtils.h | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/netwerk/ipc/NeckoMessageUtils.h b/netwerk/ipc/NeckoMessageUtils.h index 4e93f7f555..975eb0b235 100644 --- a/netwerk/ipc/NeckoMessageUtils.h +++ b/netwerk/ipc/NeckoMessageUtils.h @@ -122,9 +122,12 @@ struct ParamTraits return false; if (aResult->raw.family == AF_UNSPEC) { - return aMsg->ReadBytes(aIter, - reinterpret_cast(&aResult->raw.data), - sizeof(aResult->raw.data)); + const char *tmp; + if (aMsg->ReadBytes(aIter, &tmp, sizeof(aResult->raw.data))) { + memcpy(&(aResult->raw.data), tmp, sizeof(aResult->raw.data)); + return true; + } + return false; } else if (aResult->raw.family == AF_INET) { return ReadParam(aMsg, aIter, &aResult->inet.port) && ReadParam(aMsg, aIter, &aResult->inet.ip); @@ -136,9 +139,12 @@ struct ParamTraits ReadParam(aMsg, aIter, &aResult->inet6.scope_id); #if defined(XP_UNIX) } else if (aResult->raw.family == AF_LOCAL) { - return aMsg->ReadBytes(aIter, - reinterpret_cast(&aResult->local.path), - sizeof(aResult->local.path)); + const char *tmp; + if (aMsg->ReadBytes(aIter, &tmp, sizeof(aResult->local.path))) { + memcpy(&(aResult->local.path), tmp, sizeof(aResult->local.path)); + return true; + } + return false; #endif }