diff --git a/dom/system/gonk/NetworkUtils.cpp b/dom/system/gonk/NetworkUtils.cpp index e8bb9ac038b2..c867458e5f34 100644 --- a/dom/system/gonk/NetworkUtils.cpp +++ b/dom/system/gonk/NetworkUtils.cpp @@ -819,7 +819,9 @@ void NetworkUtils::postTetherInterfaceList(CommandChain* aChain, char buf[BUF_SIZE]; NS_ConvertUTF16toUTF8 reason(aResult.mResultReason); - memcpy(buf, reason.get(), reason.Length() + 1); + + size_t length = reason.Length() + 1 < BUF_SIZE ? reason.Length() + 1 : BUF_SIZE; + memcpy(buf, reason.get(), length); split(buf, INTERFACE_DELIMIT, GET_FIELD(mInterfaceList)); doCommand(command, aChain, aCallback);