Commit 3f56ea48 authored by Steven Bennetts's avatar Steven Bennetts Committed by Commit Bot

Settings: Network: Test for empty netmask

There is an edge case where the netmask can be undefined, causing an
exception which breaks the UI. This handles that edge case.

Bug: 1091567
Change-Id: I40eb7e8b57670fd9582a28fa5723ac221cdf550c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2364002
Commit-Queue: Steven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarJon Mann <jonmann@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799830}
parent 8efc55d5
......@@ -49,11 +49,14 @@ const getRoutingPrefixAsNetmask = function(prefixLength) {
*/
const getRoutingPrefixAsLength = function(netmask) {
'use strict';
let prefixLength = 0;
if (!netmask) {
return chromeos.networkConfig.mojom.NO_ROUTING_PREFIX;
}
const tokens = netmask.split('.');
if (tokens.length !== 4) {
return -1;
return chromeos.networkConfig.mojom.NO_ROUTING_PREFIX;
}
let prefixLength = 0;
for (let i = 0; i < tokens.length; ++i) {
const token = tokens[i];
// If we already found the last mask and the current one is not
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment