diff options
Diffstat (limited to '')
-rw-r--r-- | testsuites/psxtests/psxpasswd02/init.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/testsuites/psxtests/psxpasswd02/init.c b/testsuites/psxtests/psxpasswd02/init.c index 48b66196b1..2a78becfaf 100644 --- a/testsuites/psxtests/psxpasswd02/init.c +++ b/testsuites/psxtests/psxpasswd02/init.c @@ -17,6 +17,7 @@ #include <unistd.h> #include <fcntl.h> #include <errno.h> +#include <limits.h> void print_passwd( struct passwd *pw @@ -63,6 +64,9 @@ rtems_task Init( struct passwd *pw; struct group *gr; int status = -1; + char str[100] = {0}; + int max_int = INT_MAX; + int limit_value = 0; FILE *fp = NULL; @@ -127,6 +131,28 @@ rtems_task Init( rtems_test_assert( !pw ); rtems_test_assert( errno == EINVAL ); + fp = fopen( "/etc/passwd", "w" ); + rtems_test_assert( fp != NULL ); + fprintf( fp, "user:x:999999999999:1:dummy::/:/bin/sh\n" ); + fclose( fp ); + + puts( "Init - getpwnam(\"root\") -- expected EINVAL" ); + pw = getpwnam( "root" ); + rtems_test_assert( !pw ); + rtems_test_assert( errno == EINVAL ); + + sprintf( str, "user:x:%d%d:1:dummy::/:/bin/sh\n", max_int/10, max_int%10+1 ); + + fp = fopen( "/etc/passwd", "w" ); + rtems_test_assert( fp != NULL ); + fprintf( fp, str ); + fclose( fp ); + + puts( "Init - getpwnam(\"root\") -- expected EINVAL" ); + pw = getpwnam( "root" ); + rtems_test_assert( !pw ); + rtems_test_assert( errno == EINVAL ); + puts( "Init - getgrent() -- OK" ); gr = getgrent(); rtems_test_assert( gr != NULL ); |