Skip to content

Commit

Permalink
Fix accidentally positive HTTPS upgrade error code
Browse files Browse the repository at this point in the history
ERR_DNS_NAME_HTTPS_ONLY was accidentally +809 instead of -809.

Also add some validation to ensure nobody accidentally makes a similar
invalid error in the future.

Bug: 1225776
Change-Id: I977733159de0f77e6701551d0948b73b22476114
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3098285
Reviewed-by: David Benjamin <davidben@chromium.org>
Commit-Queue: Eric Orth <ericorth@chromium.org>
Cr-Commit-Position: refs/heads/master@{#912367}
  • Loading branch information
Eric Orth authored and Chromium LUCI CQ committed Aug 16, 2021
1 parent 190de62 commit 651bd32
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion net/base/net_error_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -1000,4 +1000,4 @@ NET_ERROR(DNS_SECURE_RESOLVER_HOSTNAME_RESOLUTION_FAILED, -808)
// DNS identified the request as disallowed for insecure connection (http/ws).
// Error should be handled as if an HTTP redirect was received to redirect to
// https or wss.
NET_ERROR(DNS_NAME_HTTPS_ONLY, 809)
NET_ERROR(DNS_NAME_HTTPS_ONLY, -809)
6 changes: 6 additions & 0 deletions net/base/net_errors.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@

namespace net {

// Validate all error values in net_error_list.h are negative.
#define NET_ERROR(label, value) \
static_assert(value < 0, "ERR_" #label " should be negative");
#include "net/base/net_error_list.h"
#undef NET_ERROR

std::string ErrorToString(int error) {
return "net::" + ErrorToShortString(error);
}
Expand Down

0 comments on commit 651bd32

Please sign in to comment.