Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
settings: fix the save in gzip format
  • Loading branch information
perexg committed Feb 11, 2016
1 parent f5c85bc commit 553ef4f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/settings.c
Expand Up @@ -183,8 +183,8 @@ hts_settings_save(htsmsg_t *record, const char *pathfmt, ...)
} else {
#if ENABLE_ZLIB
r = htsmsg_binary_serialize(record, &msgdata, &msglen, 0x10000);
if (!r) {
r = tvh_gzip_deflate_fd_header(fd, msgdata, msglen, 3);
if (!r && msglen >= 4) {
r = tvh_gzip_deflate_fd_header(fd, msgdata + 4, msglen - 4, 3);
if (r)
ok = 0;
}
Expand Down
14 changes: 8 additions & 6 deletions src/zlib.c
Expand Up @@ -162,12 +162,14 @@ int tvh_gzip_deflate_fd_header ( int fd, const uint8_t *data, size_t orig, int s
r = tvh_write(fd, "\xff\xffGZIP00\x00\x00\x00\x00", 12);
if (r)
return 1;
r = tvh_gzip_deflate_fd(fd, data, orig, &size, 3) < 0;
if (r || size > UINT_MAX)
return 1;
r = lseek(fd, 8, SEEK_SET) != (off_t)8;
if (r)
return 1;
if (orig > 0) {
r = tvh_gzip_deflate_fd(fd, data, orig, &size, 3) < 0;
if (r || size > UINT_MAX)
return 1;
r = lseek(fd, 8, SEEK_SET) != (off_t)8;
if (r)
return 1;
}
data2[0] = (orig >> 24) & 0xff;
data2[1] = (orig >> 16) & 0xff;
data2[2] = (orig >> 8) & 0xff;
Expand Down

0 comments on commit 553ef4f

Please sign in to comment.