OpenCoverage

sftp-glob.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssh/src/sftp-glob.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9-
10-
11int remote_glob(struct sftp_conn *, const char *, int,-
12 int (*)(const char *, int), _ssh_compat_glob_t *);-
13-
14struct SFTP_OPENDIR {-
15 SFTP_DIRENT **dir;-
16 int offset;-
17};-
18-
19static struct {-
20 struct sftp_conn *conn;-
21} cur;-
22-
23static void *-
24fudge_opendir(const char *path)-
25{-
26 struct SFTP_OPENDIR *r;-
27-
28 r = xcalloc(1, sizeof(*r));-
29-
30 if (do_readdir(cur.conn, (char *)path, &r->dir)
do_readdir(cur...path, &r->dir)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
31 free(r);-
32 return
never executed: return( ((void *)0) );
(
never executed: return( ((void *)0) );
0
33 ((void *)0)
never executed: return( ((void *)0) );
0
34 );
never executed: return( ((void *)0) );
0
35 }-
36-
37 r->offset = 0;-
38-
39 return
never executed: return((void *)r);
((void *)r);
never executed: return((void *)r);
0
40}-
41-
42static struct dirent *-
43fudge_readdir(struct SFTP_OPENDIR *od)-
44{-
45-
46 static char buf[sizeof(struct dirent) + -
47 4096-
48 ];-
49 struct dirent *ret = (struct dirent *)buf;-
50-
51 static int inum = 1;-
52-
53-
54 if (od->dir[od->offset] ==
od->dir[od->of...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
55 ((void *)0)
od->dir[od->of...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
56 )-
57 return
never executed: return( ((void *)0) );
(
never executed: return( ((void *)0) );
0
58 ((void *)0)
never executed: return( ((void *)0) );
0
59 );
never executed: return( ((void *)0) );
0
60-
61 memset(buf, 0, sizeof(buf));-
62 strlcpy(ret->d_name, od->dir[od->offset++]->filename,-
63 sizeof(ret->d_name));-
64-
65-
66-
67-
68-
69-
70-
71 ret->d_ino = inum++;-
72 if (!inum
!inumDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
73 inum = 1;
never executed: inum = 1;
0
74-
75-
76 return
never executed: return(ret);
(ret);
never executed: return(ret);
0
77}-
78-
79static void-
80fudge_closedir(struct SFTP_OPENDIR *od)-
81{-
82 free_sftp_dirents(od->dir);-
83 free(od);-
84}
never executed: end of block
0
85-
86static int-
87fudge_lstat(const char *path, struct stat *st)-
88{-
89 Attrib *a;-
90-
91 if (!(a = do_lstat(cur.conn, (char *)path, 1))
!(a = do_lstat...ar *)path, 1))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
92 return
never executed: return(-1);
(-1);
never executed: return(-1);
0
93-
94 attrib_to_stat(a, st);-
95-
96 return
never executed: return(0);
(0);
never executed: return(0);
0
97}-
98-
99static int-
100fudge_stat(const char *path, struct stat *st)-
101{-
102 Attrib *a;-
103-
104 if (!(a = do_stat(cur.conn, (char *)path, 1))
!(a = do_stat(...ar *)path, 1))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
105 return
never executed: return(-1);
(-1);
never executed: return(-1);
0
106-
107 attrib_to_stat(a, st);-
108-
109 return
never executed: return(0);
(0);
never executed: return(0);
0
110}-
111-
112int-
113remote_glob(struct sftp_conn *conn, const char *pattern, int flags,-
114 int (*errfunc)(const char *, int), _ssh_compat_glob_t *pglob)-
115{-
116 pglob->gl_opendir = fudge_opendir;-
117 pglob->gl_readdir = (struct dirent *(*)(void *))fudge_readdir;-
118 pglob->gl_closedir = (void (*)(void *))fudge_closedir;-
119 pglob->gl_lstat = fudge_lstat;-
120 pglob->gl_stat = fudge_stat;-
121-
122 memset(&cur, 0, sizeof(cur));-
123 cur.conn = conn;-
124-
125 return
never executed: return(_ssh__compat_glob(pattern, flags | 0x0040, errfunc, pglob));
(_ssh__compat_glob(pattern, flags | 0x0040, errfunc, pglob));
never executed: return(_ssh__compat_glob(pattern, flags | 0x0040, errfunc, pglob));
0
126}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.2