[PATCH v2 2/3] lib: parse_area_spec: part of the area spec after -/+ should start with a digit

Peter Mamonov pmamonov at gmail.com
Mon Jan 15 03:32:32 PST 2018


Signed-off-by: Peter Mamonov <pmamonov at gmail.com>
---
 lib/misc.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lib/misc.c b/lib/misc.c
index 1767043d1..fc2c45aa4 100644
--- a/lib/misc.c
+++ b/lib/misc.c
@@ -96,6 +96,9 @@ int parse_area_spec(const char *str, loff_t *start, loff_t *size)
 
 	if (*str == '-') {
 		/* beginning and end given */
+		if (!isdigit(*(str + 1)))
+			return -1;
+
 		end = strtoull_suffix(str + 1, NULL, 0);
 		if (end < *start) {
 			printf("end < start\n");
@@ -107,6 +110,9 @@ int parse_area_spec(const char *str, loff_t *start, loff_t *size)
 
 	if (*str == '+') {
 		/* beginning and size given */
+		if (!isdigit(*(str + 1)))
+			return -1;
+
 		*size = strtoull_suffix(str + 1, NULL, 0);
 		goto success;
 	}
-- 
2.11.0




More information about the barebox mailing list