git-svn: trunk@2123
Tomasz Kojm authored on 2006/07/26 01:34:40... | ... |
@@ -256,22 +256,24 @@ struct cl_cvd *cl_cvdhead(const char *file) |
256 | 256 |
FILE *fs; |
257 | 257 |
char head[513]; |
258 | 258 |
int i; |
259 |
+ unsigned int bread; |
|
260 |
+ |
|
259 | 261 |
|
260 | 262 |
if((fs = fopen(file, "rb")) == NULL) { |
261 | 263 |
cli_dbgmsg("Can't open CVD file %s\n", file); |
262 | 264 |
return NULL; |
263 | 265 |
} |
264 | 266 |
|
265 |
- if((i = fread(head, 1, 512, fs)) != 512) { |
|
266 |
- cli_dbgmsg("Short read (%d) while reading CVD head from %s\n", i, file); |
|
267 |
+ if(!(bread = fread(head, 1, 512, fs))) { |
|
268 |
+ cli_errmsg("Can't read CVD header of %s\n", file); |
|
267 | 269 |
fclose(fs); |
268 | 270 |
return NULL; |
269 | 271 |
} |
270 | 272 |
|
271 | 273 |
fclose(fs); |
272 | 274 |
|
273 |
- head[512] = 0; |
|
274 |
- for(i = 511; i > 0 && (head[i] == ' ' || head[i] == 10); head[i] = 0, i--); |
|
275 |
+ head[bread] = 0; |
|
276 |
+ for(i = bread - 1; i > 0 && (head[i] == ' ' || head[i] == '\n' || head[i] == '\r'); head[i] = 0, i--); |
|
275 | 277 |
|
276 | 278 |
return cl_cvdparse(head); |
277 | 279 |
} |