void pause_sound_if_necessary_and_play_video(const char *name, int skip, int flags) { int musplaying = play.cur_music_number, i; int ambientWas[MAX_SOUND_CHANNELS]; for (i = 1; i < MAX_SOUND_CHANNELS; i++) ambientWas[i] = ambient[i].channel; if ((strlen(name) > 3) && (stricmp(&name[strlen(name) - 3], "ogv") == 0)) { play_theora_video(name, skip, flags); } else { char videoFilePath[MAX_PATH]; get_current_dir_path(videoFilePath, name); platform->PlayVideo(videoFilePath, skip, flags); } if (flags < 10) { update_music_volume(); // restart the music if (musplaying >= 0) newmusic (musplaying); for (i = 1; i < MAX_SOUND_CHANNELS; i++) { if (ambientWas[i] > 0) PlayAmbientSound(ambientWas[i], ambient[i].num, ambient[i].vol, ambient[i].x, ambient[i].y); } } }
bool validate_user_file_path(const char *fnmm, char *output, bool currentDirOnly) { if (strncmp(fnmm, "$SAVEGAMEDIR$", 13) == 0) { fnmm += 14; sprintf(output, "%s%s", saveGameDirectory, fnmm); } else if (strncmp(fnmm, "$APPDATADIR$", 12) == 0) { fnmm += 13; const char *appDataDir = platform->GetAllUsersDataDirectory(); if (appDataDir == NULL) appDataDir = "."; if (game.saveGameFolderName[0] != 0) { sprintf(output, "%s/%s", appDataDir, game.saveGameFolderName); fix_filename_slashes(output); mkdir(output); } else { strcpy(output, appDataDir); } put_backslash(output); strcat(output, fnmm); } else { get_current_dir_path(output, fnmm); } // don't allow access to files outside current dir if (!currentDirOnly) { } else if ((strchr (fnmm, '/') != NULL) || (strchr(fnmm, '\\') != NULL) || (strstr(fnmm, "..") != NULL) || (strchr(fnmm, ':') != NULL)) { debug_log("Attempt to access file '%s' denied (not current directory)", fnmm); return false; } return true; }