zlint icon indicating copy to clipboard operation
zlint copied to clipboard

Inconsistency in `IsOnionV2Address` util function

Open mathewhodson opened this issue 3 years ago • 0 comments

The IsOnionV2Address function comments say, "The second-to-the-right most label is a 16 character long, base32." The code actually seems to check the left-most label.

Based on similar code in IsOnionV3Address, the code in IsOnionV2Address should be updated to this:

address := labels[len(labels)-2]
if len(address) != 16 {
	return false
}
_, err := onionBase32Encoding.DecodeString(address)

Originally posted by @mathewhodson in https://github.com/zmap/zlint/pull/677#discussion_r894899072

mathewhodson avatar Jul 02 '22 14:07 mathewhodson