diff options
author | lurchi <lurchi@strangeplace.net> | 2018-01-07 18:35:39 +0100 |
---|---|---|
committer | lurchi <lurchi@strangeplace.net> | 2018-01-07 18:35:39 +0100 |
commit | 638642f8a3d750d77c501bcd565c05c2f98bbc2d (patch) | |
tree | 9e4dc18cc438ef641bbea50654501958b0a58b76 /src | |
parent | c5e402ace9dff0bb5b27ebc8cc553175fbeceb68 (diff) | |
download | gnunet-638642f8a3d750d77c501bcd565c05c2f98bbc2d.tar.gz gnunet-638642f8a3d750d77c501bcd565c05c2f98bbc2d.zip |
properly check size of MsgProcRequest
Diffstat (limited to 'src')
-rw-r--r-- | src/social/gnunet-service-social.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/social/gnunet-service-social.c b/src/social/gnunet-service-social.c index 520df20b9..60f1b348d 100644 --- a/src/social/gnunet-service-social.c +++ b/src/social/gnunet-service-social.c | |||
@@ -1392,19 +1392,23 @@ msg_proc_parse (const struct MsgProcRequest *mpreq, | |||
1392 | const char **method_prefix, | 1392 | const char **method_prefix, |
1393 | struct GNUNET_HashCode *method_hash) | 1393 | struct GNUNET_HashCode *method_hash) |
1394 | { | 1394 | { |
1395 | uint8_t method_size = ntohs (mpreq->header.size) - sizeof (*mpreq); | 1395 | ssize_t method_size = ntohs (mpreq->header.size) - sizeof (*mpreq); |
1396 | uint16_t offset = GNUNET_STRINGS_buffer_tokenize ((const char *) &mpreq[1], | 1396 | uint16_t offset = GNUNET_STRINGS_buffer_tokenize ((const char *) &mpreq[1], |
1397 | method_size, 1, method_prefix); | 1397 | method_size, 1, method_prefix); |
1398 | 1398 | ||
1399 | if (method_size < 0) | ||
1400 | { | ||
1401 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1402 | "MsgProcRequest has invalid size\n"); | ||
1403 | return GNUNET_SYSERR; | ||
1404 | } | ||
1399 | if (0 == offset || offset != method_size || *method_prefix == NULL) | 1405 | if (0 == offset || offset != method_size || *method_prefix == NULL) |
1400 | { | 1406 | { |
1401 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1407 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1402 | "offset = %u, method_size = %u, method_name = %s\n", | 1408 | "MsgProcRequest contains invalid method\n"); |
1403 | offset, method_size, *method_prefix); | ||
1404 | return GNUNET_SYSERR; | 1409 | return GNUNET_SYSERR; |
1405 | } | 1410 | } |
1406 | 1411 | GNUNET_CRYPTO_hash (*method_prefix, (size_t) method_size, method_hash); | |
1407 | GNUNET_CRYPTO_hash (*method_prefix, method_size, method_hash); | ||
1408 | *flags = ntohl (mpreq->flags); | 1412 | *flags = ntohl (mpreq->flags); |
1409 | return GNUNET_OK; | 1413 | return GNUNET_OK; |
1410 | } | 1414 | } |