Fix bugs and make code tinier

- Fixed bug where stdio eof wasn't being sticky
- Fixed bug where fseeko() wasn't clearing eof state
- Removed assert() usage from libc favoring _unassert() / _npassert()
This commit is contained in:
Justine Tunney 2022-10-09 22:38:28 -07:00
parent 9b7c8db846
commit d5910e2673
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
115 changed files with 510 additions and 290 deletions

View file

@ -16,11 +16,9 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/dce.h"
#include "libc/intrin/asan.internal.h"
#include "libc/log/check.h"
#include "libc/mem/gc.h"
#include "libc/nexgen32e/x86feature.h"
#include "libc/mem/gc.internal.h"
#include "libc/runtime/runtime.h"
#include "libc/str/str.h"
#include "third_party/mbedtls/bignum_internal.h"
@ -189,8 +187,8 @@ mbedtls_p384_mul( uint64_t X[12],
}
else
{
if( A == X ) A = gc( memcpy( malloc( 6 * 8 ), A, 6 * 8 ) );
if( B == X ) B = gc( memcpy( malloc( 6 * 8 ), B, 6 * 8 ) );
if( A == X ) A = _gc( memcpy( malloc( 6 * 8 ), A, 6 * 8 ) );
if( B == X ) B = _gc( memcpy( malloc( 6 * 8 ), B, 6 * 8 ) );
Mul( X, A, n, B, m );
mbedtls_platform_zeroize( X + n + m, (12 - n - m) * 8 );
}
@ -305,7 +303,7 @@ mbedtls_p384_add( uint64_t X[7],
ADC( X[5], A[5], B[5], c, X[6] );
#endif
mbedtls_p384_rum( X );
DCHECK_EQ(0, X[6]);
MBEDTLS_ASSERT(0 == X[6]);
}
static void
@ -350,7 +348,7 @@ mbedtls_p384_sub( uint64_t X[7],
#endif
while( (int64_t)X[6] < 0 )
mbedtls_p384_gro( X );
DCHECK_EQ(0, X[6]);
MBEDTLS_ASSERT(0 == X[6]);
}
static void
@ -378,7 +376,7 @@ mbedtls_p384_hub( uint64_t A[7],
: "rax", "rcx", "memory", "cc");
while( (int64_t)A[6] < 0 )
mbedtls_p384_gro( A );
DCHECK_EQ(0, A[6]);
MBEDTLS_ASSERT(0 == A[6]);
#else
mbedtls_p384_sub(A, A, B);
#endif
@ -460,11 +458,11 @@ int mbedtls_p384_add_mixed( const mbedtls_ecp_group *G,
s.Zn = mbedtls_mpi_limbs( &P->Z );
s.QXn = mbedtls_mpi_limbs( &Q->X );
s.QYn = mbedtls_mpi_limbs( &Q->Y );
CHECK_LE( s.Xn, 6 );
CHECK_LE( s.Yn, 6 );
CHECK_LE( s.Zn, 6 );
CHECK_LE( s.QXn, 6 );
CHECK_LE( s.QYn, 6 );
MBEDTLS_ASSERT( s.Xn <= 6 );
MBEDTLS_ASSERT( s.Yn <= 6 );
MBEDTLS_ASSERT( s.Zn <= 6 );
MBEDTLS_ASSERT( s.QXn <= 6 );
MBEDTLS_ASSERT( s.QYn <= 6 );
memcpy( s.X, P->X.p, s.Xn * 8 );
memcpy( s.Y, P->Y.p, s.Yn * 8 );
memcpy( s.Z, P->Z.p, s.Zn * 8 );