================== SV_WriteDownloadToClient Check to see if the client wants a file, open it if needed and start pumping the client Fill up msg with data ================== */
| 712 | ================== |
| 713 | */ |
| 714 | void SV_WriteDownloadToClient(client_t *cl, msg_t *msg) |
| 715 | { |
| 716 | int curindex; |
| 717 | int rate; |
| 718 | int blockspersnap; |
| 719 | int unreferenced = 1; |
| 720 | char errorMessage[1024]; |
| 721 | char pakbuf[MAX_QPATH], *pakptr; |
| 722 | int numRefPaks; |
| 723 | |
| 724 | if (!*cl->downloadName) |
| 725 | return; // Nothing being downloaded |
| 726 | |
| 727 | if(!cl->download) |
| 728 | { |
| 729 | qboolean idPack = qfalse; |
| 730 | qboolean missionPack = qfalse; |
| 731 | |
| 732 | // Chop off filename extension. |
| 733 | Com_sprintf(pakbuf, sizeof(pakbuf), "%s", cl->downloadName); |
| 734 | pakptr = strrchr(pakbuf, '.'); |
| 735 | |
| 736 | if(pakptr) |
| 737 | { |
| 738 | *pakptr = '\0'; |
| 739 | |
| 740 | // Check for pk3 filename extension |
| 741 | if(!Q_stricmp(pakptr + 1, "pk3")) |
| 742 | { |
| 743 | const char *referencedPaks = FS_ReferencedPakNames(); |
| 744 | |
| 745 | // Check whether the file appears in the list of referenced |
| 746 | // paks to prevent downloading of arbitrary files. |
| 747 | Cmd_TokenizeStringIgnoreQuotes(referencedPaks); |
| 748 | numRefPaks = Cmd_Argc(); |
| 749 | |
| 750 | for(curindex = 0; curindex < numRefPaks; curindex++) |
| 751 | { |
| 752 | if(!FS_FilenameCompare(Cmd_Argv(curindex), pakbuf)) |
| 753 | { |
| 754 | unreferenced = 0; |
| 755 | |
| 756 | // now that we know the file is referenced, |
| 757 | // check whether it's legal to download it. |
| 758 | missionPack = FS_idPak(pakbuf, "missionpack"); |
| 759 | idPack = missionPack; |
| 760 | idPack = (qboolean)(idPack || FS_idPak(pakbuf, BASEGAME)); |
| 761 | |
| 762 | break; |
| 763 | } |
| 764 | } |
| 765 | } |
| 766 | } |
| 767 | |
| 768 | cl->download = 0; |
| 769 | |
| 770 | // We open the file here |
| 771 | if ( !sv_allowDownload->integer || |
no test coverage detected