summaryrefslogtreecommitdiff
path: root/src/usr.bin/nc/netcat.c (unfollow)
Commit message (Collapse)AuthorFilesLines
2021-12-29Plug memleaktb1-3/+3
CID 345160
2021-12-29Set failed in test_random_points()tb1-2/+2
CID 345141
2021-12-28Fix typo in commenttb1-2/+2
2021-12-28Use lowercase letters for hexadecimal constants, as both jsing and Itb1-15/+15
prefer this.
2021-12-28Rewrite X509v3_addr_canonize() with new accessorstb1-7/+9
This is again a straightforward conversion and leads to something which matches our usual style more. ok jsing
2021-12-28Validate AFIs before sorting in X509v3_adr_canonize()tb1-1/+7
Again, we're dealing with necessarily not fully validated data here, so a check up front seems prudent. ok jsing
2021-12-28Rewrite/simplify X509v3_addr_is_canonical()tb1-40/+36
This is a more or less straightforward conversion using the new IPAddressFamily accessor API. As a result, some checks have become a bit stricter, which is only desirable here. ok jsing
2021-12-28Check AFI/SAFI before comparing them in X509v3_addr_is_canonical()tb1-1/+8
As mentioned in a previous commit, IPAddressFamily_cmp() can't really check for trailing garbage in addressFamily->data. Since the path validation and hence the X.509 validator call X509v3_addr_is_canonical(), this deals with only partially validated data. ok jsing
2021-12-28Make IPAddressFamily_cmp() more pleasing on the eyetb1-4/+11
Define and use MINIMUM() instead of a ternary operator and separate the code from the declarations. Also, we can spare a line to make the return legible instead of squeezing it into another ternary operator. addressFamily->data contains a two-bytes AFI and an optional one-byte SAFI. This function currently also compares any trailing garbage that may be present. Since comparison functions can't really error, this needs to be checked bofore it is used. Such checks will be added in subsequent commits. ok jsing
2021-12-28Style improvements in X509v3_addr_add_range()tb1-8/+15
ok jsing
2021-12-28Style improvements in X509v3_addr_add_prefix()tb1-7/+16
ok jsing
2021-12-28Another small readability tweak in X509v3_addr_inherits()tb1-2/+3
Declare IPAddressFamily before using it.
2021-12-28Use an accessor in X509v3_addr_inherits()tb1-2/+2
2021-12-28Add a comment to i2r_IPAddrBlocks that we may want/have to deal withtb1-1/+2
unknown address family types. Pointed out by jsing during review.
2021-12-28Add a few accessors for IPAddressFamily and make first use of themtb1-25/+94
One reason why this file is hard to read are endless repetitions of checks and assignments reaching deep inside structs. This can be made much more readable by adding a bunch of accessors. As a first step, we deal with IPAddressFamily, where we want to check the type of the ipAddressChoice member, check whether the inheritance element is present or access the addressOrRanges field. This diff already makes minimal use of these accessors to appease -Werror. More use and additional accessors will follow in later passes. ok inoguchi jsing
2021-12-28Simplify and explain expand_addr() a bittb1-12/+23
RFC 3779 section 2.1.2 does a decent job of explaining how IP addresses are encoded in. What's stored amounts to a prefix with all trailing zero octets omitted. If there are trailing zero bits in the last non-zero octet, bs->flags & 7 indicates how many. addr_expand() expands this to an address of length 4 or 16 depending on whether we deal with IPv4 or IPv6. Since an address can be the lower or the upper bound of a prefix or address range, expansion needs to be able to zero-fill or one-fill the unused bits/octets. No other expansion is ever used, so simplify the meaning of fill accordingly. There's no need to special case the case that there are no unused bits, the masking/filling is a noop. ok jsing
2021-12-28Add a comment so I don't forget to think about input validationtb1-1/+3
in make_IPAddressFamily()
2021-12-28Convert make_IPAddressFamily to CBS/CBBtb1-13/+26
The IPAddrBlocks type, which represents the IPAddrBlocks extension, should have exactly one IPAddressFamily per AFI+SAFI combination to be delegated. make_IPAddressFamily() first builds up a search key from the afi and safi arguments and then looks for an existing IPAddressFamily with that key in the IPAddrBlocks that was passed in. It returns that if it finds it or allocates and adds a new one. This diff preserves the current behavior that the afi and *safi arguments are truncated to 2 and 1 bytes, respectively. This may change in the future. ok inoguchi jsing
2021-12-28Remove two pointless NULL checks and allocationstb1-7/+1
The ASN.1 template for IPAddressFamily doesn't mark either of its two members as optional, so they are allocated by IPAddressFamily_new(). ok inoguchi jsing
2021-12-28Check for trailing garbage in X509_addr_get_afi()tb1-1/+5
Per RFC 3779 2.2.3.3, the addressFamily field contains the 2-byte AFI and an optional 1-byte SAFI. Nothing else. The optional SAFI is nowhere exposed in the API. It is used expliclty only for pretty printing. There are implicit uses in a few places, notably for sorting/comparing where trailing garbage would be erroneously taken into account. Erroring in this situation will let us avoid this in upcoming revisions. ok inoguchi jsing
2021-12-28Convert X509v3_adr_get_afi() to CBStb1-6/+21
The manual byte bashing is performed more safely using this API which would have avoided the out-of-bounds read that this API had until a few years back. The API is somewhat strange in that it uses the reserved AFI 0 as an in-band error but it doesn't care about the reserved AFI 65535. ok inoguchi jsing
2021-12-27Pull BN_{new,init,clear,clear_free,free} up to the top of bn_lib.cjsing1-58/+58
Discussed with tb@
2021-12-27Provide a set of RSA and ECDSA test certificates/keys.jsing30-0/+919
These are generated using the make-certs.sh script.