[lib-result] Check validity of the request type

This commit is contained in:
Matteo Cypriani 2013-09-25 11:42:25 -04:00
parent d995cdfc7d
commit b39ccb8f1e
1 changed files with 7 additions and 1 deletions

View File

@ -93,7 +93,7 @@ owl_result* owl_fill_result(char *csv)
long longfield ; // Return value of owl_read_long_field() long longfield ; // Return value of owl_read_long_field()
owl_result *result = NULL ; owl_result *result = NULL ;
result = malloc(sizeof(owl_result)) ; result = malloc(sizeof(*result)) ;
if (! result) if (! result)
{ {
perror("Cannot allocate memory") ; perror("Cannot allocate memory") ;
@ -128,6 +128,12 @@ owl_result* owl_fill_result(char *csv)
"Error reading the request type from the CSV string!\n") ; "Error reading the request type from the CSV string!\n") ;
goto error ; goto error ;
} }
if (! OWL_IS_REQUEST_TYPE(longfield))
{
fprintf(stderr,
"The request type read (%ld) is invalid!\n", longfield) ;
goto error ;
}
result->request_type = longfield ; result->request_type = longfield ;
/* Timestamp */ /* Timestamp */