| 398 | static hashtable<const char *, memfile> memfiles; // table of all memfiles |
| 399 | |
| 400 | static void mountzip(ziparchive &arch, const char *mountdir, const char *stripdir, bool allowconfig) |
| 401 | { |
| 402 | string mdir = "", fname; |
| 403 | if(mountdir) |
| 404 | { |
| 405 | copystring(mdir, mountdir); |
| 406 | if(fixpackagedir(mdir) <= 1) mdir[0] = '\0'; |
| 407 | } |
| 408 | int striplen = stripdir ? (int)strlen(stripdir) : 0; |
| 409 | |
| 410 | loopv(arch.files) |
| 411 | { // build full path names - and check them |
| 412 | zipfile *zf = &arch.files[i]; |
| 413 | formatstring(fname)("%s%s", mdir, striplen && !strncmp(zf->name, stripdir, striplen) ? zf->name + striplen : zf->name); |
| 414 | path(fname); |
| 415 | unixpath(fname); |
| 416 | zf->fullname = newstring(fname); |
| 417 | zf->location = &arch; |
| 418 | filtertext(fname, fname, FTXT__MEDIAFILEPATH); |
| 419 | if(strcmp(fname, zf->fullname) || (strncmp("packages/", fname, 9) && (!allowconfig || strncmp("config/", fname, 7)))) |
| 420 | { // path is not allowed (illegal characters or illegal path) |
| 421 | #if defined(_DEBUG) && !defined(STANDALONE) |
| 422 | clientlogf("mountzip: ignored file %s from zip %s", fname, arch.name); |
| 423 | #endif |
| 424 | DELSTRING(zf->fullname); |
| 425 | } |
| 426 | else path(zf->fullname); |
| 427 | } |
| 428 | } |
| 429 | |
| 430 | static void rebuildzipfilehashtable() |
| 431 | { |
no test coverage detected