diff --git a/share/libc/unistd.h b/share/libc/unistd.h index 356ae590fc8216f13a87b3ee0b450223b6e544f8..46162fb22a34e7cd7212a610fd3b1fbae47bce53 100644 --- a/share/libc/unistd.h +++ b/share/libc/unistd.h @@ -745,7 +745,25 @@ extern int access(const char *path, int amode); extern unsigned int alarm(unsigned int); extern int brk(void *); + +/*@ // missing: may assign to errno: EACCES, ELOOP, ENAMETOOLONG, ENOENT, + // ENOTDIR + // missing: assigns \result \from 'filesystem' + requires valid_string_path: valid_read_string(path); + assigns \result \from indirect:path, indirect:path[0..]; + ensures result_ok_or_error: \result == 0 || \result == -1; +*/ extern int chdir(const char *path); + + +/*@ // missing: may assign to errno: EACCES, ELOOP, ENAMETOOLONG, ENOENT, + // ENOTDIR, EPERM + // missing: assigns \result \from 'filesystem, permissions' + // missing: assigns 'filesystem view' \from path[0..]; + requires valid_string_path: valid_read_string(path); + assigns \result \from indirect:path, indirect:path[0..]; + ensures result_ok_or_error: \result == 0 || \result == -1; +*/ extern int chroot(const char *path); diff --git a/src/plugins/variadic/tests/erroneous/oracle/exec.res.oracle b/src/plugins/variadic/tests/erroneous/oracle/exec.res.oracle index 7e86be9c572d9ccbcd807afe986f33adeef1e7d3..a1cffb94e46af0146e39f33ff418129358bf9178 100644 --- a/src/plugins/variadic/tests/erroneous/oracle/exec.res.oracle +++ b/src/plugins/variadic/tests/erroneous/oracle/exec.res.oracle @@ -1,8 +1,8 @@ -[variadic] FRAMAC_SHARE/libc/unistd.h:795: +[variadic] FRAMAC_SHARE/libc/unistd.h:813: Declaration of variadic function execl. -[variadic] FRAMAC_SHARE/libc/unistd.h:800: +[variadic] FRAMAC_SHARE/libc/unistd.h:818: Declaration of variadic function execle. -[variadic] FRAMAC_SHARE/libc/unistd.h:805: +[variadic] FRAMAC_SHARE/libc/unistd.h:823: Declaration of variadic function execlp. [variadic] tests/erroneous/exec.c:5: Warning: Incorrect type for argument 3. The argument will be cast from int to char *. diff --git a/src/plugins/variadic/tests/known/oracle/exec.res.oracle b/src/plugins/variadic/tests/known/oracle/exec.res.oracle index 075e93f7f68373a6e6822a2c71d3accdf50b3c91..ccda67e7ad24969af80102884259c962ece1a69b 100644 --- a/src/plugins/variadic/tests/known/oracle/exec.res.oracle +++ b/src/plugins/variadic/tests/known/oracle/exec.res.oracle @@ -1,8 +1,8 @@ -[variadic] FRAMAC_SHARE/libc/unistd.h:795: +[variadic] FRAMAC_SHARE/libc/unistd.h:813: Declaration of variadic function execl. -[variadic] FRAMAC_SHARE/libc/unistd.h:800: +[variadic] FRAMAC_SHARE/libc/unistd.h:818: Declaration of variadic function execle. -[variadic] FRAMAC_SHARE/libc/unistd.h:805: +[variadic] FRAMAC_SHARE/libc/unistd.h:823: Declaration of variadic function execlp. [variadic] tests/known/exec.c:9: Translating call to execle to a call to execve. [variadic] tests/known/exec.c:11: Warning: diff --git a/src/plugins/variadic/tests/known/oracle/exec_failed_requirement.res.oracle b/src/plugins/variadic/tests/known/oracle/exec_failed_requirement.res.oracle index 97c267c20a2bb8ac2485287265d8d119b734e857..cb9e737d1bb5298bcc7fd0690090dfd1d7406b6c 100644 --- a/src/plugins/variadic/tests/known/oracle/exec_failed_requirement.res.oracle +++ b/src/plugins/variadic/tests/known/oracle/exec_failed_requirement.res.oracle @@ -1,8 +1,8 @@ -[variadic] FRAMAC_SHARE/libc/unistd.h:795: +[variadic] FRAMAC_SHARE/libc/unistd.h:813: Declaration of variadic function execl. -[variadic] FRAMAC_SHARE/libc/unistd.h:800: +[variadic] FRAMAC_SHARE/libc/unistd.h:818: Declaration of variadic function execle. -[variadic] FRAMAC_SHARE/libc/unistd.h:805: +[variadic] FRAMAC_SHARE/libc/unistd.h:823: Declaration of variadic function execlp. [variadic] tests/known/exec_failed_requirement.c:7: Translating call to execl to a call to execv. diff --git a/tests/libc/oracle/fc_libc.0.res.oracle b/tests/libc/oracle/fc_libc.0.res.oracle index ba81dc3d6039cf8489dcec07f828cb488595f2b3..9077994133db4509739dd6e9f53481051b1f2a6b 100644 --- a/tests/libc/oracle/fc_libc.0.res.oracle +++ b/tests/libc/oracle/fc_libc.0.res.oracle @@ -40,7 +40,7 @@ unsetenv (0 call); wcscat (0 call); wcscpy (0 call); wcslen (2 calls); wcsncat (0 call); wcsncpy (0 call); wmemcpy (0 call); wmemset (0 call); - Undefined functions (379) + Undefined functions (381) ========================= FD_CLR (0 call); FD_ISSET (0 call); FD_SET (0 call); FD_ZERO (0 call); Frama_C_int_interval (0 call); Frama_C_long_interval (0 call); @@ -73,48 +73,49 @@ atan2f (0 call); atanf (0 call); atanl (0 call); atexit (0 call); atof (0 call); atol (0 call); atoll (0 call); basename (0 call); bind (0 call); bsearch (0 call); bzero (0 call); ceil (0 call); - ceilf (0 call); ceill (0 call); chown (0 call); clearerr (0 call); - clearerr_unlocked (0 call); clock (0 call); clock_gettime (0 call); - clock_nanosleep (0 call); close (0 call); closedir (0 call); - closelog (0 call); connect (0 call); cos (0 call); cosf (0 call); - cosl (0 call); creat (0 call); ctime (0 call); difftime (0 call); - dirname (0 call); div (0 call); drand48 (0 call); dup (0 call); - dup2 (0 call); erand48 (0 call); execl (0 call); execle (0 call); - execlp (0 call); execv (0 call); execve (0 call); execvp (0 call); - exit (0 call); exp (0 call); expf (0 call); fabsl (0 call); fclose (0 call); - fcntl (0 call); fdopen (0 call); feof (2 calls); feof_unlocked (0 call); - ferror (2 calls); ferror_unlocked (0 call); fflush (0 call); fgetc (1 call); - fgetpos (0 call); fgets (0 call); fgetws (0 call); fileno (0 call); - fileno_unlocked (0 call); flock (0 call); flockfile (0 call); - floor (0 call); floorf (0 call); floorl (0 call); fmod (0 call); - fmodf (0 call); fopen (0 call); fork (0 call); fputc (0 call); - fputs (0 call); fread (0 call); free (1 call); freeaddrinfo (0 call); - freopen (0 call); fseek (0 call); fsetpos (0 call); ftell (0 call); - ftrylockfile (0 call); funlockfile (0 call); fwrite (0 call); - gai_strerror (0 call); getc (0 call); getc_unlocked (0 call); - getchar (0 call); getchar_unlocked (0 call); getcwd (0 call); - getegid (0 call); geteuid (0 call); getgid (0 call); gethostname (0 call); - getitimer (0 call); getopt (0 call); getopt_long (0 call); - getopt_long_only (0 call); getpgid (0 call); getpgrp (0 call); - getpid (0 call); getppid (0 call); getpriority (0 call); getpwnam (0 call); - getpwuid (0 call); getresgid (0 call); getresuid (0 call); - getrlimit (0 call); getrusage (0 call); gets (0 call); getsid (0 call); - getsockopt (0 call); gettimeofday (0 call); getuid (0 call); - gmtime (0 call); htonl (0 call); htons (0 call); iconv (0 call); - iconv_close (0 call); iconv_open (0 call); inet_addr (2 calls); - inet_ntoa (0 call); inet_ntop (0 call); inet_pton (0 call); - isascii (0 call); isatty (0 call); jrand48 (0 call); kill (0 call); - killpg (0 call); labs (0 call); lcong48 (0 call); ldiv (0 call); - listen (0 call); llabs (0 call); lldiv (0 call); localtime (0 call); - log (0 call); log10 (0 call); log10f (0 call); log10l (0 call); - log2 (0 call); log2f (0 call); log2l (0 call); logf (0 call); logl (0 call); - longjmp (0 call); lrand48 (0 call); malloc (7 calls); mblen (0 call); - mbstowcs (0 call); mbtowc (0 call); mkdir (0 call); mkstemp (0 call); - mktime (0 call); mrand48 (0 call); nan (0 call); nanf (0 call); - nanl (0 call); nanosleep (0 call); nrand48 (0 call); ntohl (0 call); - ntohs (0 call); open (0 call); openat (0 call); opendir (0 call); - openlog (0 call); pathconf (0 call); pclose (0 call); perror (0 call); - pipe (0 call); poll (0 call); popen (0 call); pow (0 call); powf (0 call); + ceilf (0 call); ceill (0 call); chdir (0 call); chown (0 call); + chroot (0 call); clearerr (0 call); clearerr_unlocked (0 call); + clock (0 call); clock_gettime (0 call); clock_nanosleep (0 call); + close (0 call); closedir (0 call); closelog (0 call); connect (0 call); + cos (0 call); cosf (0 call); cosl (0 call); creat (0 call); ctime (0 call); + difftime (0 call); dirname (0 call); div (0 call); drand48 (0 call); + dup (0 call); dup2 (0 call); erand48 (0 call); execl (0 call); + execle (0 call); execlp (0 call); execv (0 call); execve (0 call); + execvp (0 call); exit (0 call); exp (0 call); expf (0 call); fabsl (0 call); + fclose (0 call); fcntl (0 call); fdopen (0 call); feof (2 calls); + feof_unlocked (0 call); ferror (2 calls); ferror_unlocked (0 call); + fflush (0 call); fgetc (1 call); fgetpos (0 call); fgets (0 call); + fgetws (0 call); fileno (0 call); fileno_unlocked (0 call); flock (0 call); + flockfile (0 call); floor (0 call); floorf (0 call); floorl (0 call); + fmod (0 call); fmodf (0 call); fopen (0 call); fork (0 call); + fputc (0 call); fputs (0 call); fread (0 call); free (1 call); + freeaddrinfo (0 call); freopen (0 call); fseek (0 call); fsetpos (0 call); + ftell (0 call); ftrylockfile (0 call); funlockfile (0 call); + fwrite (0 call); gai_strerror (0 call); getc (0 call); + getc_unlocked (0 call); getchar (0 call); getchar_unlocked (0 call); + getcwd (0 call); getegid (0 call); geteuid (0 call); getgid (0 call); + gethostname (0 call); getitimer (0 call); getopt (0 call); + getopt_long (0 call); getopt_long_only (0 call); getpgid (0 call); + getpgrp (0 call); getpid (0 call); getppid (0 call); getpriority (0 call); + getpwnam (0 call); getpwuid (0 call); getresgid (0 call); + getresuid (0 call); getrlimit (0 call); getrusage (0 call); gets (0 call); + getsid (0 call); getsockopt (0 call); gettimeofday (0 call); + getuid (0 call); gmtime (0 call); htonl (0 call); htons (0 call); + iconv (0 call); iconv_close (0 call); iconv_open (0 call); + inet_addr (2 calls); inet_ntoa (0 call); inet_ntop (0 call); + inet_pton (0 call); isascii (0 call); isatty (0 call); jrand48 (0 call); + kill (0 call); killpg (0 call); labs (0 call); lcong48 (0 call); + ldiv (0 call); listen (0 call); llabs (0 call); lldiv (0 call); + localtime (0 call); log (0 call); log10 (0 call); log10f (0 call); + log10l (0 call); log2 (0 call); log2f (0 call); log2l (0 call); + logf (0 call); logl (0 call); longjmp (0 call); lrand48 (0 call); + malloc (7 calls); mblen (0 call); mbstowcs (0 call); mbtowc (0 call); + mkdir (0 call); mkstemp (0 call); mktime (0 call); mrand48 (0 call); + nan (0 call); nanf (0 call); nanl (0 call); nanosleep (0 call); + nrand48 (0 call); ntohl (0 call); ntohs (0 call); open (0 call); + openat (0 call); opendir (0 call); openlog (0 call); pathconf (0 call); + pclose (0 call); perror (0 call); pipe (0 call); poll (0 call); + popen (0 call); pow (0 call); powf (0 call); pthread_cond_broadcast (0 call); pthread_cond_destroy (0 call); pthread_cond_init (0 call); pthread_cond_wait (0 call); pthread_create (0 call); pthread_join (0 call); @@ -177,7 +178,7 @@ Goto = 89 Assignment = 438 Exit point = 82 - Function = 461 + Function = 463 Function call = 89 Pointer dereferencing = 158 Cyclomatic complexity = 286 diff --git a/tests/libc/oracle/fc_libc.1.res.oracle b/tests/libc/oracle/fc_libc.1.res.oracle index ade6066676f8cb6ce2f274aa0cef0907bb02c75a..46a7daf3a80476931d58f62f30b136b84c6c7463 100644 --- a/tests/libc/oracle/fc_libc.1.res.oracle +++ b/tests/libc/oracle/fc_libc.1.res.oracle @@ -7318,6 +7318,20 @@ extern int tcsetattr(int fd, int optional_actions, struct termios *termios_p); */ extern int access(char const *path, int amode); +/*@ requires valid_string_path: valid_read_string(path); + ensures result_ok_or_error: \result ≡ 0 ∨ \result ≡ -1; + assigns \result; + assigns \result \from (indirect: path), (indirect: *(path + (0 ..))); + */ +extern int chdir(char const *path); + +/*@ requires valid_string_path: valid_read_string(path); + ensures result_ok_or_error: \result ≡ 0 ∨ \result ≡ -1; + assigns \result; + assigns \result \from (indirect: path), (indirect: *(path + (0 ..))); + */ +extern int chroot(char const *path); + /*@ requires valid_string_path: valid_read_string(path); ensures result_ok_or_error: \result ≡ 0 ∨ \result ≡ -1; assigns \result; diff --git a/tests/libc/oracle/unistd_h.0.res.oracle b/tests/libc/oracle/unistd_h.0.res.oracle index 601aea128cd1b0dfe1a2be81ffebe18c3f91a743..13fef3820e2033fcea8eefc8f370b31d944338a5 100644 --- a/tests/libc/oracle/unistd_h.0.res.oracle +++ b/tests/libc/oracle/unistd_h.0.res.oracle @@ -1,6 +1,8 @@ [kernel] Parsing tests/libc/unistd_h.c (with preprocessing) [eva] Splitting return states on: \return(access) == 0 (auto) + \return(chdir) == 0 (auto) + \return(chroot) == 0 (auto) \return(chown) == 0 (auto) \return(dup) == -1 (auto) \return(getcwd) == 0 (auto) @@ -501,6 +503,21 @@ [eva] computing for function chown <- main. Called from tests/libc/unistd_h.c:84. [eva] Done for function chown +[eva] computing for function chdir <- main. + Called from tests/libc/unistd_h.c:86. +[eva] using specification for function chdir +[eva] tests/libc/unistd_h.c:86: + function chdir: precondition 'valid_string_path' got status valid. +[eva] Done for function chdir +[eva] computing for function chroot <- main. + Called from tests/libc/unistd_h.c:88. +[eva] using specification for function chroot +[eva] tests/libc/unistd_h.c:88: + function chroot: precondition 'valid_string_path' got status valid. +[eva] Done for function chroot +[eva] computing for function chroot <- main. + Called from tests/libc/unistd_h.c:88. +[eva] Done for function chroot [eva] Recording results for main [eva] done for function main [eva] ====== VALUES COMPUTED ====== diff --git a/tests/libc/oracle/unistd_h.1.res.oracle b/tests/libc/oracle/unistd_h.1.res.oracle index c0be6ee4a9af72fb649805d000c4ac3967d6c467..d81948aa342cb4d58d91c65300dd1772bc54eadc 100644 --- a/tests/libc/oracle/unistd_h.1.res.oracle +++ b/tests/libc/oracle/unistd_h.1.res.oracle @@ -1,6 +1,8 @@ [kernel] Parsing tests/libc/unistd_h.c (with preprocessing) [eva] Splitting return states on: \return(access) == 0 (auto) + \return(chdir) == 0 (auto) + \return(chroot) == 0 (auto) \return(chown) == 0 (auto) \return(dup) == -1 (auto) \return(getcwd) == 0 (auto) @@ -501,6 +503,21 @@ [eva] computing for function chown <- main. Called from tests/libc/unistd_h.c:84. [eva] Done for function chown +[eva] computing for function chdir <- main. + Called from tests/libc/unistd_h.c:86. +[eva] using specification for function chdir +[eva] tests/libc/unistd_h.c:86: + function chdir: precondition 'valid_string_path' got status valid. +[eva] Done for function chdir +[eva] computing for function chroot <- main. + Called from tests/libc/unistd_h.c:88. +[eva] using specification for function chroot +[eva] tests/libc/unistd_h.c:88: + function chroot: precondition 'valid_string_path' got status valid. +[eva] Done for function chroot +[eva] computing for function chroot <- main. + Called from tests/libc/unistd_h.c:88. +[eva] Done for function chroot [eva] Recording results for main [eva] done for function main [eva] ====== VALUES COMPUTED ====== diff --git a/tests/libc/unistd_h.c b/tests/libc/unistd_h.c index b6eba6c732ceee7e6be079621580bfec33ba7991..b98727450e8373158e5814f75357260cf2186f2e 100644 --- a/tests/libc/unistd_h.c +++ b/tests/libc/unistd_h.c @@ -82,5 +82,10 @@ int main() { char *tty = ttyname(1); r = chown("/tmp/a.txt", 01000, 01000); + + r = chdir("/tmp/"); + + r = chroot("/tmp"); + return 0; }