1
0
Fork 0
mirror of git://git.psyc.eu/libpsyc synced 2024-08-15 03:19:02 +00:00

added check for invalid flags combination

This commit is contained in:
Marenz 2011-04-30 15:48:52 +02:00
parent 10e8deff47
commit 293f9160ae
2 changed files with 7 additions and 0 deletions

View file

@ -21,6 +21,7 @@
typedef enum typedef enum
{ {
/// Parse only the header
PSYC_PARSE_HEADER_ONLY = 1, PSYC_PARSE_HEADER_ONLY = 1,
/// Expects only the content part of a packet. The length of the content must fit exactly in this case /// Expects only the content part of a packet. The length of the content must fit exactly in this case
PSYC_PARSE_BEGIN_AT_CONTENT = 2, PSYC_PARSE_BEGIN_AT_CONTENT = 2,
@ -32,6 +33,8 @@ typedef enum
*/ */
typedef enum typedef enum
{ {
/// Invalid combination of flags
PSYC_PARSE_ERROR_INVALID_FLAGS = -10,
PSYC_PARSE_ERROR_END = -9, PSYC_PARSE_ERROR_END = -9,
PSYC_PARSE_ERROR_BODY = -8, PSYC_PARSE_ERROR_BODY = -8,
PSYC_PARSE_ERROR_METHOD = -7, PSYC_PARSE_ERROR_METHOD = -7,

View file

@ -136,6 +136,10 @@ inline psycParseRC psyc_parseName(psycParseState* state, psycString* name)
*/ */
inline psycParseRC psyc_parseBinaryValue(psycParseState* state, psycString* value, size_t* length, size_t* parsed) inline psycParseRC psyc_parseBinaryValue(psycParseState* state, psycString* value, size_t* length, size_t* parsed)
{ {
if (state->flags & PSYC_PARSE_HEADER_ONLY &&
state->flags & PSYC_PARSE_BEGIN_AT_CONTENT)
return PSYC_PARSE_ERROR_INVALID_FLAGS;
size_t remaining = *length - *parsed; size_t remaining = *length - *parsed;
value->ptr = state->buffer.ptr + state->cursor; value->ptr = state->buffer.ptr + state->cursor;