diff options
author | netblue30 <netblue30@yahoo.com> | 2017-10-04 08:29:31 -0400 |
---|---|---|
committer | netblue30 <netblue30@yahoo.com> | 2017-10-04 08:29:31 -0400 |
commit | 63e177af7278012d7064d4e1695d3a500f51c9eb (patch) | |
tree | 57b64ed01d1b888f2bc3db304a4928c6bd2eaa61 /src/fldd | |
parent | updated authors list (diff) | |
download | firejail-63e177af7278012d7064d4e1695d3a500f51c9eb.tar.gz firejail-63e177af7278012d7064d4e1695d3a500f51c9eb.tar.zst firejail-63e177af7278012d7064d4e1695d3a500f51c9eb.zip |
private-lib: add std C library and locale by default
Diffstat (limited to 'src/fldd')
-rw-r--r-- | src/fldd/main.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/fldd/main.c b/src/fldd/main.c index 5fda45266..6127a4a87 100644 --- a/src/fldd/main.c +++ b/src/fldd/main.c | |||
@@ -94,12 +94,12 @@ static void storage_print(Storage *ptr, int fd) { | |||
94 | } | 94 | } |
95 | } | 95 | } |
96 | 96 | ||
97 | static bool ptr_ok(const void *ptr, const void *base, const void *end, const char *name) { | 97 | static bool ptr_ok(const void *ptr, const void *base, const void *end, const char *name, const char *exe) { |
98 | bool r; | 98 | bool r; |
99 | 99 | ||
100 | r = (ptr >= base && ptr <= end); | 100 | r = (ptr >= base && ptr <= end); |
101 | if (!r && !arg_quiet) | 101 | if (!r && !arg_quiet) |
102 | fprintf(stderr, "Warning: fldd: bad pointer %s\n", name); | 102 | fprintf(stderr, "Warning: fldd: bad pointer %s for %s\n", name, exe); |
103 | return r; | 103 | return r; |
104 | } | 104 | } |
105 | 105 | ||
@@ -130,11 +130,11 @@ static void copy_libs_for_exe(const char *exe) { | |||
130 | } | 130 | } |
131 | 131 | ||
132 | Elf_Phdr *pbuf = (Elf_Phdr *)(base + sizeof(*ebuf)); | 132 | Elf_Phdr *pbuf = (Elf_Phdr *)(base + sizeof(*ebuf)); |
133 | while (ebuf->e_phnum-- > 0 && ptr_ok(pbuf, base, end, "pbuf")) { | 133 | while (ebuf->e_phnum-- > 0 && ptr_ok(pbuf, base, end, "pbuf", exe)) { |
134 | switch (pbuf->p_type) { | 134 | switch (pbuf->p_type) { |
135 | case PT_INTERP: | 135 | case PT_INTERP: |
136 | // dynamic loader ld-linux.so | 136 | // dynamic loader ld-linux.so |
137 | if (!ptr_ok(base + pbuf->p_offset, base, end, "base + pbuf->p_offset")) | 137 | if (!ptr_ok(base + pbuf->p_offset, base, end, "base + pbuf->p_offset", exe)) |
138 | goto close; | 138 | goto close; |
139 | 139 | ||
140 | storage_add(&libs, base + pbuf->p_offset); | 140 | storage_add(&libs, base + pbuf->p_offset); |
@@ -144,16 +144,16 @@ static void copy_libs_for_exe(const char *exe) { | |||
144 | } | 144 | } |
145 | 145 | ||
146 | Elf_Shdr *sbuf = (Elf_Shdr *)(base + ebuf->e_shoff); | 146 | Elf_Shdr *sbuf = (Elf_Shdr *)(base + ebuf->e_shoff); |
147 | if (!ptr_ok(sbuf, base, end, "sbuf")) | 147 | if (!ptr_ok(sbuf, base, end, "sbuf", exe)) |
148 | goto close; | 148 | goto close; |
149 | 149 | ||
150 | // Find strings section | 150 | // Find strings section |
151 | char *strbase = NULL; | 151 | char *strbase = NULL; |
152 | int sections = ebuf->e_shnum; | 152 | int sections = ebuf->e_shnum; |
153 | while (sections-- > 0 && ptr_ok(sbuf, base, end, "sbuf")) { | 153 | while (sections-- > 0 && ptr_ok(sbuf, base, end, "sbuf", exe)) { |
154 | if (sbuf->sh_type == SHT_STRTAB) { | 154 | if (sbuf->sh_type == SHT_STRTAB) { |
155 | strbase = base + sbuf->sh_offset; | 155 | strbase = base + sbuf->sh_offset; |
156 | if (!ptr_ok(strbase, base, end, "strbase")) | 156 | if (!ptr_ok(strbase, base, end, "strbase", exe)) |
157 | goto close; | 157 | goto close; |
158 | break; | 158 | break; |
159 | } | 159 | } |
@@ -164,7 +164,7 @@ static void copy_libs_for_exe(const char *exe) { | |||
164 | 164 | ||
165 | // Find dynamic section | 165 | // Find dynamic section |
166 | sections = ebuf->e_shnum; | 166 | sections = ebuf->e_shnum; |
167 | while (sections-- > 0 && ptr_ok(sbuf, base, end, "sbuf")) { | 167 | while (sections-- > 0 && ptr_ok(sbuf, base, end, "sbuf", exe)) { |
168 | // TODO: running fldd on large gui programs (fldd /usr/bin/transmission-qt) | 168 | // TODO: running fldd on large gui programs (fldd /usr/bin/transmission-qt) |
169 | // crash on accessing memory location sbuf->sh_type if sbuf->sh_type in the previous section was 0 (SHT_NULL) | 169 | // crash on accessing memory location sbuf->sh_type if sbuf->sh_type in the previous section was 0 (SHT_NULL) |
170 | // for now we just exit the while loop - this is probably incorrect | 170 | // for now we just exit the while loop - this is probably incorrect |
@@ -173,14 +173,14 @@ static void copy_libs_for_exe(const char *exe) { | |||
173 | break; | 173 | break; |
174 | if (sbuf->sh_type == SHT_DYNAMIC) { | 174 | if (sbuf->sh_type == SHT_DYNAMIC) { |
175 | Elf_Dyn *dbuf = (Elf_Dyn *)(base + sbuf->sh_offset); | 175 | Elf_Dyn *dbuf = (Elf_Dyn *)(base + sbuf->sh_offset); |
176 | if (!ptr_ok(dbuf, base, end, "dbuf")) | 176 | if (!ptr_ok(dbuf, base, end, "dbuf", exe)) |
177 | goto close; | 177 | goto close; |
178 | // Find DT_RPATH/DT_RUNPATH tags first | 178 | // Find DT_RPATH/DT_RUNPATH tags first |
179 | unsigned long size = sbuf->sh_size; | 179 | unsigned long size = sbuf->sh_size; |
180 | while (size >= sizeof(*dbuf) && ptr_ok(dbuf, base, end, "dbuf")) { | 180 | while (size >= sizeof(*dbuf) && ptr_ok(dbuf, base, end, "dbuf", exe)) { |
181 | if (dbuf->d_tag == DT_RPATH || dbuf->d_tag == DT_RUNPATH) { | 181 | if (dbuf->d_tag == DT_RPATH || dbuf->d_tag == DT_RUNPATH) { |
182 | const char *searchpath = strbase + dbuf->d_un.d_ptr; | 182 | const char *searchpath = strbase + dbuf->d_un.d_ptr; |
183 | if (!ptr_ok(searchpath, base, end, "searchpath")) | 183 | if (!ptr_ok(searchpath, base, end, "searchpath", exe)) |
184 | goto close; | 184 | goto close; |
185 | storage_add(&lib_paths, searchpath); | 185 | storage_add(&lib_paths, searchpath); |
186 | } | 186 | } |
@@ -190,10 +190,10 @@ static void copy_libs_for_exe(const char *exe) { | |||
190 | // Find DT_NEEDED tags | 190 | // Find DT_NEEDED tags |
191 | dbuf = (Elf_Dyn *)(base + sbuf->sh_offset); | 191 | dbuf = (Elf_Dyn *)(base + sbuf->sh_offset); |
192 | size = sbuf->sh_size; | 192 | size = sbuf->sh_size; |
193 | while (size >= sizeof(*dbuf) && ptr_ok(dbuf, base, end, "dbuf")) { | 193 | while (size >= sizeof(*dbuf) && ptr_ok(dbuf, base, end, "dbuf", exe)) { |
194 | if (dbuf->d_tag == DT_NEEDED) { | 194 | if (dbuf->d_tag == DT_NEEDED) { |
195 | const char *lib = strbase + dbuf->d_un.d_ptr; | 195 | const char *lib = strbase + dbuf->d_un.d_ptr; |
196 | if (!ptr_ok(lib, base, end, "lib")) | 196 | if (!ptr_ok(lib, base, end, "lib", exe)) |
197 | goto close; | 197 | goto close; |
198 | copy_libs_for_lib(lib); | 198 | copy_libs_for_lib(lib); |
199 | } | 199 | } |