summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Dedecker2018-06-20 12:42:11 +0000
committerHans Dedecker2018-06-20 13:27:42 +0000
commitb99c1f63b6e1897de84e0a9dc420a240271fb70c (patch)
tree771be068c14efaa95923d2a346999581c2d9b338
parentca8822bc7bd0797eaa6b6160f234471ee1a8fb2c (diff)
downloadodhcp6c-b99c1f63b6e1897de84e0a9dc420a240271fb70c.tar.gz
odhcp6c: remove len check in option parsing handle
Replace len check by checking src to determine end of option data in the different option data handlers. This will make Coverity happy as reported in CID1437049, CID1430905, CID1430898 and CID1430848 Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
-rw-r--r--src/odhcp6c.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/src/odhcp6c.c b/src/odhcp6c.c
index 2fb8abf..261513d 100644
--- a/src/odhcp6c.c
+++ b/src/odhcp6c.c
@@ -972,7 +972,6 @@ static int parse_opt_u8(const char *src, uint8_t **dst)
static int parse_opt_string(const char *src, uint8_t **dst, const bool array)
{
- int i_len = strlen(src);
int o_len = 0;
char *sep = get_sep_pos(src, ARRAY_SEP);
@@ -994,19 +993,17 @@ static int parse_opt_string(const char *src, uint8_t **dst, const bool array)
memcpy(&((*dst)[o_len]), src, len);
o_len += len;
- i_len -= strlen(src) + (sep ? 1 : 0);
src = sep;
if (sep)
sep = get_sep_pos(src, ARRAY_SEP);
- } while (i_len);
+ } while (src);
return o_len;
}
static int parse_opt_dns_string(const char *src, uint8_t **dst, const bool array)
{
- int i_len = strlen(src);
int o_len = 0;
char *sep = get_sep_pos(src, ARRAY_SEP);
@@ -1032,19 +1029,17 @@ static int parse_opt_dns_string(const char *src, uint8_t **dst, const bool array
memcpy(&((*dst)[o_len]), tmp, len);
o_len += len;
- i_len -= strlen(src) + (sep ? 1 : 0);
src = sep;
if (sep)
sep = get_sep_pos(src, ARRAY_SEP);
- } while (i_len);
+ } while (src);
return o_len;
}
static int parse_opt_ip6(const char *src, uint8_t **dst, const bool array)
{
- int i_len = strlen(src);
int o_len = 0;
char *sep = get_sep_pos(src, ARRAY_SEP);
@@ -1067,19 +1062,17 @@ static int parse_opt_ip6(const char *src, uint8_t **dst, const bool array)
return -1;
o_len += len;
- i_len -= strlen(src) + (sep ? 1 : 0);
src = sep;
if (sep)
sep = get_sep_pos(src, ARRAY_SEP);
- } while (i_len);
+ } while (src);
return o_len;
}
static int parse_opt_user_class(const char *src, uint8_t **dst, const bool array)
{
- int i_len = strlen(src);
int o_len = 0;
char *sep = get_sep_pos(src, ARRAY_SEP);
@@ -1106,12 +1099,11 @@ static int parse_opt_user_class(const char *src, uint8_t **dst, const bool array
memcpy(e->data, src, str_len);
o_len += str_len + 2;
- i_len -= str_len + (sep ? 1 : 0);
src = sep;
if (sep)
sep = get_sep_pos(src, ARRAY_SEP);
- } while (i_len);
+ } while (src);
return o_len;
}
@@ -1139,7 +1131,7 @@ static int parse_opt_data(const char *data, uint8_t **dst, const unsigned int ty
break;
case OPT_USER_CLASS:
- ret = parse_opt_user_class(data, dst,array);
+ ret = parse_opt_user_class(data, dst, array);
break;
default: