Skip to content

Commit

Permalink
compression: Fix mc_compact() crash with no 2nd parameter
Browse files Browse the repository at this point in the history
It seems something went wrong in commit 466e933, as the optimization
actually caused the function to always crash.

(cherry picked from commit 7402451)
  • Loading branch information
liviuchircu committed Nov 21, 2022
1 parent a97ec11 commit 83872a7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions modules/compression/compression.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ static int fixup_whitelist_compress(void**);
static int fixup_whitelist_free(void **);
static int fixup_mc_compact_flags(void **);

static int mc_compact(struct sip_msg* msg, mc_whitelist_p wh_list, int* flags_p);
static int mc_compact(struct sip_msg* msg, mc_whitelist_p wh_list, void* flags_p);
static int mc_compact_cb(char** buf, struct mc_compact_args* mc_compact_args, int, int*);

static int mc_compress(struct sip_msg* msg, int* algo, int* flags,
Expand Down Expand Up @@ -466,7 +466,7 @@ static int fixup_mc_compact_flags(void **param)
{
str *s = (str *) *param;
int st;
long flags = 0;
unsigned long flags = 0;

if (s) {
for (st = 0; st < s->len; st++) {
Expand All @@ -478,8 +478,9 @@ static int fixup_mc_compact_flags(void **param)
LM_WARN("unknown option `%c'\n", s->s[st]);
}
}
*param = (void *) flags;
}

*param = (void *)flags;
return 0;
}

Expand Down Expand Up @@ -623,7 +624,7 @@ static mc_whitelist_p mc_dup_whitelist(mc_whitelist_p src)
* 3) Headers which not in whitelist will be removed
* 4) Unnecessary sdp body codec attributes lower than 96 removed
*/
static int mc_compact(struct sip_msg* msg, mc_whitelist_p wh_list, int* flags_p)
static int mc_compact(struct sip_msg* msg, mc_whitelist_p wh_list, void* flags_p)
{
struct mc_compact_args *mc_compact_args_p;

Expand All @@ -643,7 +644,7 @@ static int mc_compact(struct sip_msg* msg, mc_whitelist_p wh_list, int* flags_p)
goto error;
}

mc_compact_args_p->flags = *flags_p;
mc_compact_args_p->flags = (unsigned int)(unsigned long)flags_p;
SET_GLOBAL_CTX(compact_ctx_pos, (void*)mc_compact_args_p);

/* register stateless callbacks */
Expand Down
2 changes: 1 addition & 1 deletion modules/compression/compression.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ struct mc_comp_args {

struct mc_compact_args {
mc_whitelist_p wh_list;
int flags;
unsigned int flags;
};

#endif
Expand Down

0 comments on commit 83872a7

Please sign in to comment.