Merged revisions 269417 via svnmerge from

https://origsvn.digium.com/svn/asterisk/trunk

........
  r269417 | russell | 2010-06-09 16:11:43 -0500 (Wed, 09 Jun 2010) | 6 lines
  
  Resolve an invalid memory read on an event.
  
  Valgrind pointed out that attempting to get an IE value from an event that has
  no IEs produces an invalid memory read past the end of the event.  Thanks to
  mmichelson for pointing the problem out to me and then testing the fix.
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.2@269418 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.6.2
Russell Bryant 15 years ago
parent 379d6cd25a
commit 2fd6cbc156

@ -590,9 +590,10 @@ size_t ast_event_get_size(const struct ast_event *event);
* \param iterator The iterator instance to initialize
* \param event The event that will be iterated through
*
* \return Nothing
* \retval 0 Success, there are IEs available to iterate
* \retval -1 Failure, there are no IEs in the event to iterate
*/
void ast_event_iterator_init(struct ast_event_iterator *iterator, const struct ast_event *event);
int ast_event_iterator_init(struct ast_event_iterator *iterator, const struct ast_event *event);
/*!
* \brief Move iterator instance to next IE

@ -809,12 +809,20 @@ struct ast_event_sub *ast_event_unsubscribe(struct ast_event_sub *sub)
return NULL;
}
void ast_event_iterator_init(struct ast_event_iterator *iterator, const struct ast_event *event)
int ast_event_iterator_init(struct ast_event_iterator *iterator, const struct ast_event *event)
{
int res = 0;
iterator->event_len = ntohs(event->event_len);
iterator->event = event;
if (iterator->event_len >= sizeof(*event) + sizeof(struct ast_event_ie)) {
iterator->ie = (struct ast_event_ie *) ( ((char *) event) + sizeof(*event) );
return;
} else {
iterator->ie = NULL;
res = -1;
}
return res;
}
int ast_event_iterator_next(struct ast_event_iterator *iterator)
@ -884,10 +892,11 @@ const void *ast_event_get_ie_raw(const struct ast_event *event, enum ast_event_i
struct ast_event_iterator iterator;
int res = 0;
for (ast_event_iterator_init(&iterator, event); !res; res = ast_event_iterator_next(&iterator)) {
if (ast_event_iterator_get_ie_type(&iterator) == ie_type)
for (res = ast_event_iterator_init(&iterator, event); !res; res = ast_event_iterator_next(&iterator)) {
if (ast_event_iterator_get_ie_type(&iterator) == ie_type) {
return ast_event_iterator_get_ie_raw(&iterator);
}
}
return NULL;
}

Loading…
Cancel
Save