Mercurial > audlegacy-plugins
comparison src/madplug/plugin.c @ 783:83a38bcfe7c8 trunk
[svn] - check the result of vfs_fread() strictly.
| author | yaz |
|---|---|
| date | Mon, 05 Mar 2007 00:48:01 -0800 |
| parents | 6f519e34ddf0 |
| children | 2461b711162b |
comparison
equal
deleted
inserted
replaced
| 782:6f519e34ddf0 | 783:83a38bcfe7c8 |
|---|---|
| 222 gint cyc = 0; | 222 gint cyc = 0; |
| 223 guchar buf[4]; | 223 guchar buf[4]; |
| 224 guchar tmp[4096]; | 224 guchar tmp[4096]; |
| 225 gint ret, i; | 225 gint ret, i; |
| 226 | 226 |
| 227 if (fin == NULL) | |
| 228 return 0; | |
| 229 | |
| 227 info.remote = FALSE; | 230 info.remote = FALSE; |
| 228 | 231 |
| 229 if(audmad_is_remote(filename)) | 232 if(audmad_is_remote(filename)) |
| 230 info.remote = TRUE; | 233 info.remote = TRUE; |
| 231 | 234 |
| 234 if ((ext != NULL) && | 237 if ((ext != NULL) && |
| 235 (!strcasecmp("flac", ext) || !strcasecmp("mpc", ext) || | 238 (!strcasecmp("flac", ext) || !strcasecmp("mpc", ext) || |
| 236 !strcasecmp("tta", ext) || !strcasecmp("ogg", ext) || | 239 !strcasecmp("tta", ext) || !strcasecmp("ogg", ext) || |
| 237 !strcasecmp("wma", ext) ) | 240 !strcasecmp("wma", ext) ) |
| 238 ) | 241 ) |
| 239 return FALSE; | 242 return 0; |
| 240 | 243 |
| 241 if (fin == NULL) | 244 if(vfs_fread(buf, 1, 4, fin) == 0) |
| 242 return FALSE; | 245 return 0; |
| 243 | |
| 244 vfs_fread(buf, 1, 4, fin); | |
| 245 | 246 |
| 246 check = mp3_head_convert(buf); | 247 check = mp3_head_convert(buf); |
| 247 | 248 |
| 248 if (memcmp(buf, "ID3", 3) == 0) | 249 if (memcmp(buf, "ID3", 3) == 0) |
| 249 return 1; | 250 return 1; |
| 250 else if (memcmp(buf, "OggS", 4) == 0) | 251 else if (memcmp(buf, "OggS", 4) == 0) |
| 251 return 0; | 252 return 0; |
| 252 else if (memcmp(buf, "RIFF", 4) == 0) | 253 else if (memcmp(buf, "RIFF", 4) == 0) |
| 253 { | 254 { |
| 254 vfs_fseek(fin, 4, SEEK_CUR); | 255 vfs_fseek(fin, 4, SEEK_CUR); |
| 255 vfs_fread(buf, 1, 4, fin); | 256 if(vfs_fread(buf, 1, 4, fin) == 0) |
| 257 return 0; | |
| 256 | 258 |
| 257 if (memcmp(buf, "RMP3", 4) == 0) | 259 if (memcmp(buf, "RMP3", 4) == 0) |
| 258 return 1; | 260 return 1; |
| 259 } | 261 } |
| 260 | 262 |
| 261 while (!mp3_head_check(check)) | 263 while (!mp3_head_check(check)) |
| 262 { | 264 { |
| 263 ret = vfs_fread(tmp, 1, 4096, fin); | 265 if(vfs_fread(tmp, 1, 4096, fin) == 0) |
| 264 if (ret == 0) | |
| 265 return 0; | 266 return 0; |
| 266 | 267 |
| 267 for (i = 0; i < ret; i++) | 268 for (i = 0; i < ret; i++) |
| 268 { | 269 { |
| 269 check <<= 8; | 270 check <<= 8; |
