[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r31945 - gnunet/src/scalarproduct
From: |
gnunet |
Subject: |
[GNUnet-SVN] r31945 - gnunet/src/scalarproduct |
Date: |
Fri, 17 Jan 2014 07:39:51 +0100 |
Author: LRN
Date: 2014-01-17 07:39:51 +0100 (Fri, 17 Jan 2014)
New Revision: 31945
Modified:
gnunet/src/scalarproduct/gnunet-scalarproduct.c
Log:
Fix scalarproduct argument parsing (don't scan past 0-terminator)
Modified: gnunet/src/scalarproduct/gnunet-scalarproduct.c
===================================================================
--- gnunet/src/scalarproduct/gnunet-scalarproduct.c 2014-01-17 04:13:01 UTC
(rev 31944)
+++ gnunet/src/scalarproduct/gnunet-scalarproduct.c 2014-01-17 06:39:51 UTC
(rev 31945)
@@ -257,19 +257,21 @@
/* Count input_elements_peer1, and put in elements_peer1 array */
do
{
- // get the length of the current element and replace , with null
+ // get the length of the current element
for (end = begin; *end && *end != ','; end++);
- if (1 == sscanf (begin, "%" SCNd32 ",", &element))
+ if (0 == *begin)
{
+ break;
+ }
+ else if (1 == sscanf (begin, "%" SCNd32 ",", &element))
+ {
//element in the middle
element_count++;
- begin = end + 1;
+ begin = end;
+ if (',' == *end)
+ begin += 1;
}
- else if (0 == *begin)
- {
- break;
- }
else
{
LOG (GNUNET_ERROR_TYPE_ERROR,
@@ -291,18 +293,26 @@
/* Read input_elements_peer1, and put in elements_peer1 array */
do
{
- // get the length of the current element and replace , with null
+ // get the length of the current element
for (end = begin; *end && *end != ','; end++);
- if (1 == sscanf (begin, "%" SCNd32 ",", &elements[element_count]))
+ if (0 == *begin)
{
+ break;
+ }
+ else if (1 == sscanf (begin, "%" SCNd32 ",", &elements[element_count]))
+ {
//element in the middle
element_count++;
- begin = end + 1;
+ begin = end;
+ if (',' == *end)
+ begin += 1;
}
- else if (0 == *begin)
+ else
{
- break;
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ _ ("Could not convert `%s' to int32_t.\n"), begin);
+ return;
}
}
while (1);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r31945 - gnunet/src/scalarproduct,
gnunet <=