}
memset(&config, 0, sizeof(struct config));
rv = fread((char *) &config, sizeof(struct config), 1, cfp);
- if (rv != sizeof(struct config))
+ if (rv != 1)
{
fprintf(stderr,
"Warning: The config file %s has unexpected size. \n",
{
long start_pos;
size_t bytes;
- size_t actual_bytes;
char *buf = NULL;
start_pos = extract_long(cmdbuf, 0);
buf = malloc(bytes + 1);
fseek(CC->download_fp, start_pos, 0);
- actual_bytes = fread(buf, 1, bytes, CC->download_fp);
- cprintf("%d %d\n", BINARY_FOLLOWS, (int)actual_bytes);
- client_write(buf, actual_bytes);
+ if (fread(buf, 1, bytes, CC->download_fp) == 1) {
+ cprintf("%d %d\n", BINARY_FOLLOWS, (int)bytes);
+ client_write(buf, bytes);
+ }
+ else {
+ cprintf("%d %s\n", ERROR, strerror(errno));
+ }
free(buf);
}