]> andersk Git - splint.git/blob - src/mapping_chdir.c
*** empty log message ***
[splint.git] / src / mapping_chdir.c
1
2
3 int
4 #ifdef __STDC__
5 mapping_chdir(/*@nullterminated@*/  char *orig_path) /*@bufferConstraint MaxRead(mapped_path) <= 198;MaxRead(orig_path) <= 199;  (MaxRead(orig_path) + MaxRead(mapped_path)) <= (MaxSet(mapped_path) -1 );@*/
6 #else
7 mapping_chdir( orig_path )
8   /*@nullterminated@*/    char *orig_path;
9 #endif
10 {
11       int ret;
12       char *sl, *path;
13
14       strcpy( old_mapped_path, mapped_path );
15       /*b changed from 
16         path = &pathspace[0]; */
17       
18       path = pathspace;
19       strcpy( path, orig_path );
20
21       /* / at start of path, set the start of the mapped_path to / */
22       if( path[0] == '/' ){
23               mapped_path[0] = '/';
24               mapped_path[1] = '\0';
25               path++;
26       }
27
28       while( (sl = strchr( path, '/' )) ){
29               char *dir, *last;
30               dir = path;
31               *sl = '\0';
32               path = sl + 1;
33               if( *dir )
34                       do_elem( dir );
35               if( *path == '\0' )
36                       break;
37       }
38       if( *path )
39               do_elem( path );
40
41       if( (ret = chdir( mapped_path )) < 0 ){
42               strcpy( mapped_path, old_mapped_path );
43       }
44
45       return ret;
46 }
47 /* From now on use the mapping version */
48
49 #define chdir(d) mapping_chdir(d)
50 #define getwd(d) mapping_getwd(d)
51 #define getcwd(d,u) mapping_getwd(d)
52
53 int f()
54 {
55   struct passwd *chroot_pw;
56   
57   if ((chroot_pw = getpwuid (pw->pw_uid)) != NULL)
58     if (/*strcpy ("kl", "hjklhjklhjkljhjklhjkhjkhjklhjkl") && */mapping_chdir (chroot_pw->pw_dir)/* >= 0 */)
59                       {
60                         char f[1];
61                         ///     mapping_chdir (chroot_pw->pw_dir);
62                         strcpy (f, "hjklhjklhjkljhjklhjkhjkhjklhjkl");
63                         home = sgetsave (chroot_pw->pw_dir);
64                         
65                       }
66 }
This page took 0.039649 seconds and 5 git commands to generate.