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>
static int parse_opt_string(const char *src, uint8_t **dst, const bool array)
{
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);
int o_len = 0;
char *sep = get_sep_pos(src, ARRAY_SEP);
memcpy(&((*dst)[o_len]), src, len);
o_len += len;
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);
src = sep;
if (sep)
sep = get_sep_pos(src, ARRAY_SEP);
return o_len;
}
static int parse_opt_dns_string(const char *src, uint8_t **dst, const bool array)
{
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);
int o_len = 0;
char *sep = get_sep_pos(src, ARRAY_SEP);
memcpy(&((*dst)[o_len]), tmp, len);
o_len += len;
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);
src = sep;
if (sep)
sep = get_sep_pos(src, ARRAY_SEP);
return o_len;
}
static int parse_opt_ip6(const char *src, uint8_t **dst, const bool array)
{
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);
int o_len = 0;
char *sep = get_sep_pos(src, ARRAY_SEP);
- i_len -= strlen(src) + (sep ? 1 : 0);
src = sep;
if (sep)
sep = get_sep_pos(src, ARRAY_SEP);
src = sep;
if (sep)
sep = get_sep_pos(src, ARRAY_SEP);
return o_len;
}
static int parse_opt_user_class(const char *src, uint8_t **dst, const bool array)
{
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);
int o_len = 0;
char *sep = get_sep_pos(src, ARRAY_SEP);
memcpy(e->data, src, str_len);
o_len += str_len + 2;
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);
src = sep;
if (sep)
sep = get_sep_pos(src, ARRAY_SEP);
break;
case OPT_USER_CLASS:
break;
case OPT_USER_CLASS:
- ret = parse_opt_user_class(data, dst,array);
+ ret = parse_opt_user_class(data, dst, array);