| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssh/src/sftp-glob.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||
|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||
| 2 | - | |||||||
| 3 | - | |||||||
| 4 | - | |||||||
| 5 | - | |||||||
| 6 | - | |||||||
| 7 | - | |||||||
| 8 | - | |||||||
| 9 | - | |||||||
| 10 | - | |||||||
| 11 | int remote_glob(struct sftp_conn *, const char *, int, | - | ||||||
| 12 | int (*)(const char *, int), _ssh_compat_glob_t *); | - | ||||||
| 13 | - | |||||||
| 14 | struct SFTP_OPENDIR { | - | ||||||
| 15 | SFTP_DIRENT **dir; | - | ||||||
| 16 | int offset; | - | ||||||
| 17 | }; | - | ||||||
| 18 | - | |||||||
| 19 | static struct { | - | ||||||
| 20 | struct sftp_conn *conn; | - | ||||||
| 21 | } cur; | - | ||||||
| 22 | - | |||||||
| 23 | static void * | - | ||||||
| 24 | fudge_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)
| 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: ((void *)r);return((void *)r);never executed: return((void *)r); | 0 | ||||||
| 40 | } | - | ||||||
| 41 | - | |||||||
| 42 | static struct dirent * | - | ||||||
| 43 | fudge_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] ==
| 0 | ||||||
| 55 | ((void *)0)
| 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
| 0 | ||||||
| 73 | inum = 1; never executed: inum = 1; | 0 | ||||||
| 74 | - | |||||||
| 75 | - | |||||||
| 76 | return never executed: (ret);return(ret);never executed: return(ret); | 0 | ||||||
| 77 | } | - | ||||||
| 78 | - | |||||||
| 79 | static void | - | ||||||
| 80 | fudge_closedir(struct SFTP_OPENDIR *od) | - | ||||||
| 81 | { | - | ||||||
| 82 | free_sftp_dirents(od->dir); | - | ||||||
| 83 | free(od); | - | ||||||
| 84 | } never executed: end of block | 0 | ||||||
| 85 | - | |||||||
| 86 | static int | - | ||||||
| 87 | fudge_lstat(const char *path, struct stat *st) | - | ||||||
| 88 | { | - | ||||||
| 89 | Attrib *a; | - | ||||||
| 90 | - | |||||||
| 91 | if (!(a = do_lstat(cur.conn, (char *)path, 1))
| 0 | ||||||
| 92 | return never executed: (-1);return(-1);never executed: return(-1); | 0 | ||||||
| 93 | - | |||||||
| 94 | attrib_to_stat(a, st); | - | ||||||
| 95 | - | |||||||
| 96 | return never executed: (0);return(0);never executed: return(0); | 0 | ||||||
| 97 | } | - | ||||||
| 98 | - | |||||||
| 99 | static int | - | ||||||
| 100 | fudge_stat(const char *path, struct stat *st) | - | ||||||
| 101 | { | - | ||||||
| 102 | Attrib *a; | - | ||||||
| 103 | - | |||||||
| 104 | if (!(a = do_stat(cur.conn, (char *)path, 1))
| 0 | ||||||
| 105 | return never executed: (-1);return(-1);never executed: return(-1); | 0 | ||||||
| 106 | - | |||||||
| 107 | attrib_to_stat(a, st); | - | ||||||
| 108 | - | |||||||
| 109 | return never executed: (0);return(0);never executed: return(0); | 0 | ||||||
| 110 | } | - | ||||||
| 111 | - | |||||||
| 112 | int | - | ||||||
| 113 | remote_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: (_ssh__compat_glob(pattern, flags | 0x0040, errfunc, pglob));return(_ssh__compat_glob(pattern, flags | 0x0040, errfunc, pglob));never executed: return(_ssh__compat_glob(pattern, flags | 0x0040, errfunc, pglob)); | 0 | ||||||
| 126 | } | - | ||||||
| Switch to Source code | Preprocessed file |