Skip to content

Commit

Permalink
Fix storing of parameters for notify scripts
Browse files Browse the repository at this point in the history
Signed-off-by: Quentin Armitage <quentin@armitage.org.uk>
  • Loading branch information
pqarmitage committed Jan 7, 2018
1 parent 91d05eb commit 1217caf
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/notify.c
Expand Up @@ -1104,10 +1104,16 @@ add_script_param(notify_script_t *script, char *param)
char *cmd_str;
char *args;

/* We store the args as an array of pointers to the args, terminated
* by a NULL pointer, followed by the null terminated strings themselves
*/

/* Find out how many args there are */
for (num = 0, len = 0; script->args[num]; num++)
len += sizeof(char *) + strlen(script->args[num]);
len += 2 * sizeof(char *) + strlen(param);
for (num = 0, len = 0; script->args[num]; num++) {
/* For each arg we need char *, the string, and the null termination */
len += sizeof(char *) + strlen(script->args[num]) + 1;
}
len += 2 * sizeof(char *) + strlen(param) + 1; /* Pointer for new param, termination null pointer, and the string */
num += 2;

new_args = MALLOC(len);
Expand Down

0 comments on commit 1217caf

Please sign in to comment.