summaryrefslogtreecommitdiff
path: root/src/lib/libc/stdlib/reallocarray.c (unfollow)
Commit message (Collapse)AuthorFilesLines
2022-03-14First pass clean up of ASN1_STRING code.jsing1-74/+87
Use consistent variable names (astr/src) rather than 'a', 'bs', 'str', 'v' or 'x', add some whitespace and remove some unneeded parentheses. ok inoguchi@ tb@
2022-03-13Relax the check of x509_constraints_dirname()libressl-v3.5.1tb1-2/+6
The dirname constraint must be a prefix in DER format, so relax the check from requiring equal-length strings to allow shorter names also. From Alex Wilson ok jsing
2022-03-13Add x509_constraints_validate() to x509_internal.htb1-1/+3
From Alex Wilson ok jsing
2022-03-13Check name constraints using the proper APItb1-4/+21
The previous versions were too strict and disallowed leading dots. From Alex Wilson ok jsing
2022-03-13style tweaktb1-2/+2
2022-03-13Add missing error check after strdup()tb1-2/+5
From Alex Wilson ok jsing
2022-03-13Remove free_cont from asn1_d2i_ex_primitive()/asn1_ex_c2i().jsing2-50/+31
The constructed ASN.1 handling in asn1_d2i_ex_primitive() and asn1_ex_c2i() currently has code to potentially avoid a malloc/memcpy - this is a less common code path and it introduces a bunch of complexity for minimal gain. In particular, we're manually adding a trailing NUL when ASN1_STRING_set() would already do that for us, plus we currently manually free() the data on an ASN1_STRING, rather than using freezero(). ok inoguchi@ tb@
2022-03-12Factor out change cipher spec handing code in the legacy stack.jsing3-65/+73
Factor out the code that handles the processing of a change cipher spec message that has been read in the legacy stack, deduplicating code in the DTLS stack. ok inoguchi@ tb@
2022-03-10Simple regress for NULL deref reported by Guido Vranken and fixed intb2-1/+51
bn_exp2.c r1.13.
2022-03-10unsusual -> unusualjsg1-3/+3
2022-03-08Some more c99 initializers for consistency and readabilitytb1-23/+62
2022-03-07bump for LibreSSL 3.5.1bcook1-3/+3
2022-03-05Add test coverage for i2a_ASN1_OBJECT()jsing1-3/+39
2022-03-05Fix typo in commentbket1-2/+2
OK tb@
2022-03-03Pull a len == 0 check up before malloc(len) to avoid implementationtb1-5/+5
defined behavior. ok deraadt inoguchi
2022-03-03Do not write out terminating NUL in i2a_ASN1_OBJECT()tb1-2/+2
The conversion to CBB made us write out an extra NUL since we no longer use the return value of i2t_ASN1_OBJECT() (which returns strlen(data)) but rather the size of the CBB (which includes a terminal NUL) to write out data. Issue found by anton via an openssl-ruby test failure. ok jsing
2022-03-02Unwrap a linetb1-3/+2
2022-03-02whitespacetb1-2/+2
2022-03-02Provide additional ASN1_OBJECT test coverage.jsing1-16/+114
2022-03-02Rewrite ASN1_OBJECT content to ascii/text conversion.jsing3-101/+186
Rewrite the ASN1_OBJECT content to ascii/text conversion code using CBB and CBS. Currently there is a strange split with i2t_ASN1_OBJECT() calling OBJ_obj2txt() which implements the conversion, while OBJ_txt2obj() calls back into the misnamed a2d_ASN1_OBJECT() function. Move the conversion code into asn1/a_object.c and have OBJ_txt2obj() call that instead. ok inoguchi@ tb@
2022-02-28Remove unused ivbits argument from chacha_keysetup to match otherdtucker2-4/+4
instances in the tree. ok deraadt@
2022-02-26Add regress coverage for ASN1_OBJECT public interfaces.jsing2-1/+399
2022-02-26Currently malloc caches a number of free'ed regions up to 128kotto1-33/+160
in size. This cache is indexed by size (in # of pages), so it is very quick to check. Some programs allocate and deallocate larger allocations in a frantic way. Accomodate those programs by also keeping a cache of regions between 128k and 2M, in a cache of variable sized regions. Tested by many in snaps; ok deraadt@
2022-02-24Get rid of SHA1 for comparing CRL's - use SHA512 just like we do for certs.beck3-9/+7
ok tb@
2022-02-24Remove accidentally committed debug code.tb1-3/+1
2022-02-24Minor tweakstb1-7/+8
i is a silly name for BN_num_bits(dsa->q); move a comment for readability.
2022-02-24Add sanity checks on p and q in old_dsa_priv_decode()tb1-1/+15
dsa_do_verify() has checks on dsa->p and dsa->q that ensure that p isn't overly long and that q has one of the three allowed lengths specified in FIPS 186-3, namely 160, 224, or 256. Do these checks on deserialization of DSA keys without parameters. This means that we will now reject keys we would previously deserialize. Such keys are useless in that signatures generated by them would be rejected by both LibreSSL and OpenSSL. This avoids a timeout flagged in oss-fuzz #26899 due to a ridiculous DSA key whose q has size 65KiB. The timeout comes from additional checks on DSA keys added by miod in dsa_ameth.c r1.18, especially checking such a humungous number for primality is expensive. ok jsing
2022-02-21Factor out alert handing code in the legacy stack.libressl-v3.5.0jsing3-85/+77
Pull out the code that processes incoming alerts - a chunk of the complexity is due to the fact that in TLSv1.2 and earlier, alerts can be fragmented across multiple records or multiple alerts can be delivered in a single record. In DTLS there is no way that we can reassemble fragmented alerts (although the RFC is silent on this), however we could have multiple alerts in the same record. This change means that we will handle this situation more appropriately and if we encounter a fragmented alert we will now treat this as a decode error (instead of silently ignoring it). ok beck@ tb@
2022-02-21mutibyte -> multibytejsg1-3/+3
2022-02-20Fix a buffer overread in OAEP padding removaltb1-11/+11
This only occurs on very small payloads and tightly allocated buffers that don't usually occur in practice. This is OpenSSL f61c6804 ok inoguchi jsing
2022-02-20Test OBJ_obj2txt() with NULL and short buffers.jsing1-1/+12
2022-02-19Add memory BIO small I/O tests.jsing1-1/+72
2022-02-19Remove references to performance issues caused by frequent memmove().jsing1-13/+2
ok inoguchi@ tb@
2022-02-19Reduce memmoves in memory BIOs.jsing1-22/+38
Currently, a read/write memory BIO pulls up the data via memmove() on each read. This becomes very expensive when a lot of small reads are performed, especially if there is a reasonable amount of data stored in the memory BIO. Instead, store a read offset into the buffer and only perform a memmove() to pull up the data on a write, if we have read more than 4096 bytes. This way we only perform memmove() when the space saving will potentially be of benefit, while avoiding frequent memmove() in the case of small interleaved reads and writes. Should address oss-fuzz #19881. ok inoguchi@ tb@
2022-02-19certificiate -> certificatejsg1-3/+3
2022-02-19Provide a struct bio_mem for memory BIO specific data.jsing1-47/+58
In order to fix and improve the memory BIO, we need to be able to track more than just a single BUF_MEM *. Provide a struct bio_mem (which currently only contains a BUF_MEM *) and rework the internals to use this struct. ok inoguchi@ tb@
2022-02-18Avoid gendered language in man pages when not referring to a specificjsg1-4/+4
person. Rewrite or use singular they. ok thfr@ sthen@ daniel@ ian@ job@ kmos@ jcs@ ratchov@ phessler@ and others I'm likely missing on an earlier version. feedback tj@, feedback and ok jmc@
2022-02-18Clean up and simplify memory BIO code.jsing1-124/+139
This is a first pass that uses sensible and consistent names for variables. Call the BIO 'bio' (instead of 'a', 'b', 'bp', or 'h'), drop a bunch of unnecessary casts, simplify some logic and add additional error checking. With input from and ok tb@
2022-02-18prefer https links in man pagesjsg3-9/+9
ok gnezdo@ miod@ jmc@
2022-02-18grammar/rewordjsg1-5/+7
ok jmc@
2022-02-17Add tests for memory BIO.jsing1-2/+254
2022-02-12Add test coverage for OBJ_txt2obj()/OBJ_obj2txt() with no_name == 0.jsing1-4/+99
2022-02-12Avoid potential single byte overread in asn1_parse2().jsing1-3/+4
A fix for this was previously commited in r1.32, however while this added a bounds check the logic means we still fall through and perform the overread. Fix the logic such that we only log the error if the bounds check fails. While here, flip the test around such that we check for validity then print (which is more readable and matches earlier code). ok inoguchi@ tb@
2022-02-12Revise for OBJ_obj2txt() OID arc limits.jsing1-4/+4
2022-02-12Limit OID text conversion to 64 bits per arc.jsing1-55/+16
The current implementation uses an unsigned long, then switches to BN once the arc exceeds its size. However, the complexity of BN_bn2dec() is quadratic in the length of number being converted. This means that OIDs with excessively large arcs take a lot of computation to convert to text. While the X.660 specification states that arcs are unbounded, in reality they are not overly large numbers - 640K^W64 bits ought to be enough for any arc. Remove BN entirely, switch from unsigned long to uin64_t and fail if an arc exceeds this size. Identified via oss-fuzz timeouts - should fix #41028 and #44372. ok tb@
2022-02-11Fix length check of IP addresses for name constraintstb1-2/+3
An IP address in a name constraint is actually an IP address concatenated with a netmask, so it is twice as long as usual. This fixes a third bug introduced in r1.3 and reported by Volker Schlecht ok jsing
2022-02-11Add missing error check for a2i_GENERAL_NAME()tb1-1/+3
Fixes a segfault reported by Volker Schlecht. ok jsing
2022-02-11Fix a double free in v2i_NAME_CONSTRAINTS()tb1-2/+3
a2i_GENERAL_NAME() modifies and returns the out argument that was passed in unless out == NULL, in which case it returns something freshly allocated. Thus, in v2i_GENERAL_NAME_ex() we must only free ret if out == NULL so v2i_NAME_CONSTRAINTS() can free correctly. Issue reported by Volker Schlecht ok jsing
2022-02-11Test OBJ_obj2nid() with an undefined (NID_undef) object.jsing1-2/+2
2022-02-11Make OBJ_obj2nid() work correctly with NID_undef.jsing1-3/+3
Currently OBJ_obj2nid() with NID_undef returns NID_ccitt - this is due to doing a lookup on an empty value and having NID_undef conflict with an uninitialised NID value. Somewhat based on OpenSSL 0fb99904809. ok tb@