Skip to content

Commit

Permalink
Fix crash when one daemon with compression talks to another without c…
Browse files Browse the repository at this point in the history
…ompression
  • Loading branch information
subhasisb committed Jan 15, 2019
1 parent 287f88e commit 4e9189f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/lib/Libtpp/tpp_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,6 @@ tpp_send(int sd, void *data, int len)
tpp_log_func(LOG_CRIT, __func__, "tpp deflate failed");
return -1;
}
tpp_log_func(LOG_INFO, __func__, "tpp_deflate called inside tpp_send routine");
pkt = tpp_cr_pkt(outbuf, cmprsd_len, 0);
if (pkt == NULL) {
free(outbuf);
Expand Down Expand Up @@ -3556,12 +3555,13 @@ add_part_packet(stream_t *strm, void *data, int sz)
void *uncmpr_data;

if ((uncmpr_data = tpp_inflate(tmp->data, cmprsd_len, totlen))) {
tpp_log_func(LOG_INFO, __func__, "tpp_inflate called inside add_part_packet routine");
obj = tpp_cr_pkt(uncmpr_data, totlen, 0);
if (!obj)
free(uncmpr_data);
} else
} else {
tpp_log_func(LOG_CRIT, __func__, "Decompression failed");
obj = NULL;
}
tpp_free_pkt(tmp);
}
return obj; /* packet complete */
Expand Down
11 changes: 9 additions & 2 deletions src/lib/Libtpp/tpp_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -1297,7 +1297,8 @@ tpp_inflate(void *inbuf, unsigned int inlen, unsigned int totlen)
ret = inflateInit(&strm);
if (ret != Z_OK) {
free(outbuf);
tpp_log_func(LOG_CRIT, __func__, "Decompression failed");
snprintf(tpp_get_logbuf(), TPP_LOGBUF_SZ, "Decompression Init (inflateInit) failed, ret = %d", ret);
tpp_log_func(LOG_CRIT, __func__, tpp_get_logbuf());
return NULL;
}

Expand All @@ -1312,7 +1313,8 @@ tpp_inflate(void *inbuf, unsigned int inlen, unsigned int totlen)
inflateEnd(&strm);
if (ret != Z_STREAM_END) {
free(outbuf);
tpp_log_func(LOG_CRIT, __func__, "Decompression failed");
snprintf(tpp_get_logbuf(), TPP_LOGBUF_SZ, "Decompression (inflate) failed, ret = %d", ret);
tpp_log_func(LOG_CRIT, __func__, tpp_get_logbuf());
return NULL;
}
return outbuf;
Expand All @@ -1321,30 +1323,35 @@ tpp_inflate(void *inbuf, unsigned int inlen, unsigned int totlen)
void *
tpp_multi_deflate_init(int initial_len)
{
tpp_log_func(LOG_CRIT, __func__, "TPP compression disabled");
return NULL;
}

int
tpp_multi_deflate_do(void *c, int fini, void *inbuf, unsigned int inlen)
{
tpp_log_func(LOG_CRIT, __func__, "TPP compression disabled");
return -1;
}

void *
tpp_multi_deflate_done(void *c, unsigned int *cmpr_len)
{
tpp_log_func(LOG_CRIT, __func__, "TPP compression disabled");
return NULL;
}

void *
tpp_deflate(void *inbuf, unsigned int inlen, unsigned int *outlen)
{
tpp_log_func(LOG_CRIT, __func__, "TPP compression disabled");
return NULL;
}

void *
tpp_inflate(void *inbuf, unsigned int inlen, unsigned int totlen)
{
tpp_log_func(LOG_CRIT, __func__, "TPP compression disabled");
return NULL;
}
#endif
Expand Down

0 comments on commit 4e9189f

Please sign in to comment.