Skip to content

Commit

Permalink
handle compressed configuration
Browse files Browse the repository at this point in the history
cleanup log stmts, fixed erroneous null check on return value of decode.

Signed-off-by: Mike Hansen <mike.hansen@netexperience.com>
  • Loading branch information
mikehansen1970 committed Oct 17, 2024
1 parent be3fbfe commit 891c2ca
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions proto.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,9 @@ decomp(char *src, int len)
uLong ucompSize = len + 1;
uLong compSize = compressBound(ucompSize);
char *dest = malloc(ucompSize);

if (uncompress((Bytef *)dest, &ucompSize, (Bytef *)src, compSize) != Z_OK)
{
printf("uncompress failed\n");
free(dest);
return NULL;
};
Expand Down Expand Up @@ -433,19 +433,19 @@ decode_and_inflate(struct blob_attr **encoded_param, struct blob_attr *ret[__JSO
char *cp64 = blobmsg_get_string(encoded_param[PARAMS_COMPRESS_64]);
char *cp = decode_b64(cp64, compress_sz);
if (cp == NULL) {
ULOG_ERR("base64 decode failed for configure message\n");
ULOG_ERR("base64 decode failed for message\n");
ret = NULL;
return;
}
char *params = decomp(cp, compress_sz);
if (cp == NULL) {
ULOG_ERR("failed to uncompress configure message\n");
if (params == NULL) {
ULOG_ERR("failed to uncompress message\n");
ret = NULL;
return;
}

static struct blob_buf pbuf;
blob_buf_init(&pbuf, 0);

void *c;
c = blobmsg_open_table(&pbuf, "params");
blobmsg_add_json_from_string(&pbuf, params);
Expand Down

0 comments on commit 891c2ca

Please sign in to comment.