Skip to content

Commit

Permalink
Ensure data buffer is cleared, in case of encoding error.
Browse files Browse the repository at this point in the history
Signed-off-by: Joachim Nilsson <[email protected]>
  • Loading branch information
troglobit committed Nov 21, 2015
1 parent 6ec3b6c commit a7c5c46
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions mib.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,12 +387,17 @@ static int data_alloc(data_t *data, int type)
return 0;
}

/* Sets the data buffer for the value depending on the type. Note that we
* assume the buffer was allocated to hold the maximum possible value when
* the MIB was built!
/*
* Set data buffer to its new value, depending on the type.
*
* Note: we assume the buffer was allocated to hold the maximum possible
* value when the MIB was built.
*/
static int data_set(data_t *data, int type, const void *arg)
{
/* Make sure to always initialize the buffer, in case of error below. */
memset(data->buffer, 0, data->max_length);

switch (type) {
case BER_TYPE_INTEGER:
return encode_integer(data, (intptr_t)arg);
Expand Down

0 comments on commit a7c5c46

Please sign in to comment.