| 154 | } |
| 155 | |
| 156 | static FILE *FetchFile(uint32 remlen) |
| 157 | { |
| 158 | uint32 clen = remlen; |
| 159 | char *cbuf; |
| 160 | uLongf len; |
| 161 | char *buf; |
| 162 | FILE *fp; |
| 163 | |
| 164 | if(clen > 500000) // Sanity check |
| 165 | { |
| 166 | NetError(); |
| 167 | return(0); |
| 168 | } |
| 169 | |
| 170 | //printf("Receiving file: %d...\n",clen); |
| 171 | if((fp = tmpfile())) |
| 172 | { |
| 173 | cbuf = (char *)FCEU_dmalloc(clen); //mbg merge 7/17/06 added cast |
| 174 | if(!FCEUD_RecvData(cbuf, clen)) |
| 175 | { |
| 176 | NetError(); |
| 177 | fclose(fp); |
| 178 | free(cbuf); |
| 179 | return(0); |
| 180 | } |
| 181 | |
| 182 | len = FCEU_de32lsb((uint8*)cbuf); //mbg merge 7/17/06 added cast |
| 183 | if(len > 500000) // Another sanity check |
| 184 | { |
| 185 | NetError(); |
| 186 | fclose(fp); |
| 187 | free(cbuf); |
| 188 | return(0); |
| 189 | } |
| 190 | buf = (char *)FCEU_dmalloc(len); //mbg merge 7/17/06 added cast |
| 191 | uncompress((uint8*)buf, &len, (uint8*)cbuf + 4, clen - 4); //mbg merge 7/17/06 added casts |
| 192 | |
| 193 | fwrite(buf, 1, len, fp); |
| 194 | free(buf); |
| 195 | fseek(fp, 0, SEEK_SET); |
| 196 | return(fp); |
| 197 | } |
| 198 | return(0); |
| 199 | } |
| 200 | |
| 201 | void NetplayUpdate(uint8 *joyp) |
| 202 | { |
no test coverage detected