mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-26 03:15:45 +01:00
Fix sloppiness around stricly less-than vs less or equal
Fix sloppy wording around stricly less-than vs less or equal in comments. Also fix an off-by-one error in a comparison which led to calling setrlimit if the limit was exactly the minimum required for the test, which was unnecessary but harmless. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
parent
c8dab5b41e
commit
97c57fe439
@ -75,8 +75,9 @@ void context_init_free( int reinit )
|
|||||||
void poll_beyond_fd_setsize( )
|
void poll_beyond_fd_setsize( )
|
||||||
{
|
{
|
||||||
/* Test that mbedtls_net_poll does not misbehave when given a file
|
/* Test that mbedtls_net_poll does not misbehave when given a file
|
||||||
* descriptor beyond FD_SETSIZE. This code is specific to platforms
|
* descriptor greater or equal to FD_SETSIZE. This code is specific to
|
||||||
* with a Unix-like select() function. */
|
* platforms with a Unix-like select() function, which is where
|
||||||
|
* FD_SETSIZE is a concern. */
|
||||||
|
|
||||||
struct rlimit rlim_nofile;
|
struct rlimit rlim_nofile;
|
||||||
int restore_rlim_nofile = 0;
|
int restore_rlim_nofile = 0;
|
||||||
@ -87,15 +88,15 @@ void poll_beyond_fd_setsize( )
|
|||||||
mbedtls_net_init( &ctx );
|
mbedtls_net_init( &ctx );
|
||||||
|
|
||||||
/* On many systems, by default, the maximum permitted file descriptor
|
/* On many systems, by default, the maximum permitted file descriptor
|
||||||
* number is less or equal to FD_SETSIZE. If so, raise the limit if
|
* number is less than FD_SETSIZE. If so, raise the limit if
|
||||||
* possible.
|
* possible.
|
||||||
*
|
*
|
||||||
* If the limit can't be raised, a newly open file descriptor
|
* If the limit can't be raised, a file descriptor opened by the
|
||||||
* won't be higher than FD_SETSIZE, so the test is not necessary and we
|
* net_sockets module will be less than FD_SETSIZE, so the test
|
||||||
* mark it as skipped.
|
* is not necessary and we mark it as skipped.
|
||||||
*/
|
*/
|
||||||
TEST_ASSERT( getrlimit( RLIMIT_NOFILE, &rlim_nofile ) == 0 );
|
TEST_ASSERT( getrlimit( RLIMIT_NOFILE, &rlim_nofile ) == 0 );
|
||||||
if( rlim_nofile.rlim_cur <= FD_SETSIZE + 1 )
|
if( rlim_nofile.rlim_cur < FD_SETSIZE + 1 )
|
||||||
{
|
{
|
||||||
rlim_t old_rlim_cur = rlim_nofile.rlim_cur;
|
rlim_t old_rlim_cur = rlim_nofile.rlim_cur;
|
||||||
rlim_nofile.rlim_cur = FD_SETSIZE + 1;
|
rlim_nofile.rlim_cur = FD_SETSIZE + 1;
|
||||||
@ -109,8 +110,8 @@ void poll_beyond_fd_setsize( )
|
|||||||
/* In principle, mbedtls_net_poll() with valid arguments should succeed.
|
/* In principle, mbedtls_net_poll() with valid arguments should succeed.
|
||||||
* However, we know that on Unix-like platforms (and others), this function
|
* However, we know that on Unix-like platforms (and others), this function
|
||||||
* is implemented on top of select() and fd_set, which do not support
|
* is implemented on top of select() and fd_set, which do not support
|
||||||
* file descriptors beyond FD_SETSIZE. So we expect to hit this platform
|
* file descriptors greater or equal to FD_SETSIZE. So we expect to hit
|
||||||
* limitation.
|
* this platform limitation.
|
||||||
*
|
*
|
||||||
* If mbedtls_net_poll() does not proprely check that ctx.fd is in range,
|
* If mbedtls_net_poll() does not proprely check that ctx.fd is in range,
|
||||||
* it may still happen to return the expected failure code, but if this
|
* it may still happen to return the expected failure code, but if this
|
||||||
|
Loading…
Reference in New Issue
Block a user