mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-07-26 04:54:44 +00:00
Merge pull request #185 from opensourcerouting/coverity-lib-1
Coverity foo
This commit is contained in:
commit
10c7cd3920
@ -294,27 +294,6 @@ cmd_free_strvec (vector v)
|
|||||||
vector_free (v);
|
vector_free (v);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
|
||||||
cmd_concat_strvec (vector v)
|
|
||||||
{
|
|
||||||
size_t strsize = 0;
|
|
||||||
for (unsigned int i = 0; i < vector_active (v); i++)
|
|
||||||
if (vector_slot (v, i))
|
|
||||||
strsize += strlen ((char *) vector_slot (v, i)) + 1;
|
|
||||||
|
|
||||||
if (strsize == 0)
|
|
||||||
return XSTRDUP (MTYPE_TMP, "");
|
|
||||||
|
|
||||||
char *concatenated = calloc (sizeof (char), strsize);
|
|
||||||
for (unsigned int i = 0; i < vector_active (v); i++)
|
|
||||||
{
|
|
||||||
strlcat (concatenated, (char *) vector_slot (v, i), strsize);
|
|
||||||
strlcat (concatenated, " ", strsize);
|
|
||||||
}
|
|
||||||
|
|
||||||
return concatenated;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Return prompt character of specified node. */
|
/* Return prompt character of specified node. */
|
||||||
const char *
|
const char *
|
||||||
cmd_prompt (enum node_type node)
|
cmd_prompt (enum node_type node)
|
||||||
@ -720,6 +699,8 @@ cmd_complete_command (vector vline, struct vty *vty, int *status)
|
|||||||
vector_free (comps);
|
vector_free (comps);
|
||||||
comps = NULL;
|
comps = NULL;
|
||||||
}
|
}
|
||||||
|
else if (initial_comps)
|
||||||
|
vector_free (initial_comps);
|
||||||
|
|
||||||
// comps should always be null here
|
// comps should always be null here
|
||||||
assert (!comps);
|
assert (!comps);
|
||||||
@ -805,6 +786,8 @@ cmd_execute_command_real (vector vline,
|
|||||||
// if matcher error, return corresponding CMD_ERR
|
// if matcher error, return corresponding CMD_ERR
|
||||||
if (MATCHER_ERROR(status))
|
if (MATCHER_ERROR(status))
|
||||||
{
|
{
|
||||||
|
if (argv_list)
|
||||||
|
list_delete (argv_list);
|
||||||
switch (status)
|
switch (status)
|
||||||
{
|
{
|
||||||
case MATCHER_INCOMPLETE:
|
case MATCHER_INCOMPLETE:
|
||||||
|
@ -410,7 +410,6 @@ extern int argv_find (struct cmd_token **argv, int argc, const char *text, int *
|
|||||||
|
|
||||||
extern vector cmd_make_strvec (const char *);
|
extern vector cmd_make_strvec (const char *);
|
||||||
extern void cmd_free_strvec (vector);
|
extern void cmd_free_strvec (vector);
|
||||||
extern char *cmd_concat_strvec (vector);
|
|
||||||
extern vector cmd_describe_command (vector, struct vty *, int *status);
|
extern vector cmd_describe_command (vector, struct vty *, int *status);
|
||||||
extern char **cmd_complete_command (vector, struct vty *, int *status);
|
extern char **cmd_complete_command (vector, struct vty *, int *status);
|
||||||
extern const char *cmd_prompt (enum node_type);
|
extern const char *cmd_prompt (enum node_type);
|
||||||
|
18
lib/csv.c
18
lib/csv.c
@ -239,6 +239,9 @@ csv_encode (csv_t *csv,
|
|||||||
rec = malloc(sizeof(csv_record_t));
|
rec = malloc(sizeof(csv_record_t));
|
||||||
if (!rec) {
|
if (!rec) {
|
||||||
log_error("record malloc failed\n");
|
log_error("record malloc failed\n");
|
||||||
|
if (!buf)
|
||||||
|
free(str);
|
||||||
|
va_end(list);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
csv_init_record(rec);
|
csv_init_record(rec);
|
||||||
@ -255,6 +258,7 @@ csv_encode (csv_t *csv,
|
|||||||
if (!fld) {
|
if (!fld) {
|
||||||
log_error("fld malloc failed\n");
|
log_error("fld malloc failed\n");
|
||||||
csv_remove_record(csv, rec);
|
csv_remove_record(csv, rec);
|
||||||
|
va_end(list);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if (tempc < (count - 1)) {
|
if (tempc < (count - 1)) {
|
||||||
@ -518,7 +522,7 @@ csv_concat_record (csv_t *csv,
|
|||||||
curr = (char *)calloc(1, csv->buflen);
|
curr = (char *)calloc(1, csv->buflen);
|
||||||
if (!curr) {
|
if (!curr) {
|
||||||
log_error("field str malloc failed\n");
|
log_error("field str malloc failed\n");
|
||||||
return (NULL);
|
goto out_rec;
|
||||||
}
|
}
|
||||||
rec->record = curr;
|
rec->record = curr;
|
||||||
|
|
||||||
@ -526,7 +530,7 @@ csv_concat_record (csv_t *csv,
|
|||||||
ret = strstr(rec1->record, "\n");
|
ret = strstr(rec1->record, "\n");
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
log_error("rec1 str not properly formatted\n");
|
log_error("rec1 str not properly formatted\n");
|
||||||
return (NULL);
|
goto out_curr;
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(curr, (int)(ret - rec1->record + 1), "%s", rec1->record);
|
snprintf(curr, (int)(ret - rec1->record + 1), "%s", rec1->record);
|
||||||
@ -535,7 +539,7 @@ csv_concat_record (csv_t *csv,
|
|||||||
ret = strstr(rec2->record, "\n");
|
ret = strstr(rec2->record, "\n");
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
log_error("rec2 str not properly formatted\n");
|
log_error("rec2 str not properly formatted\n");
|
||||||
return (NULL);
|
goto out_curr;
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf((curr+strlen(curr)), (int)(ret - rec2->record + 1), "%s",
|
snprintf((curr+strlen(curr)), (int)(ret - rec2->record + 1), "%s",
|
||||||
@ -556,6 +560,12 @@ csv_concat_record (csv_t *csv,
|
|||||||
csv_insert_record(csv, rec);
|
csv_insert_record(csv, rec);
|
||||||
|
|
||||||
return rec;
|
return rec;
|
||||||
|
|
||||||
|
out_curr:
|
||||||
|
free(curr);
|
||||||
|
out_rec:
|
||||||
|
free(rec);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -569,6 +579,8 @@ csv_decode (csv_t *csv, char *inbuf)
|
|||||||
pos = strpbrk(buf, "\n");
|
pos = strpbrk(buf, "\n");
|
||||||
while (pos != NULL) {
|
while (pos != NULL) {
|
||||||
rec = calloc(1, sizeof(csv_record_t));
|
rec = calloc(1, sizeof(csv_record_t));
|
||||||
|
if (!rec)
|
||||||
|
return;
|
||||||
csv_init_record(rec);
|
csv_init_record(rec);
|
||||||
TAILQ_INSERT_TAIL(&(csv->records), rec, next_record);
|
TAILQ_INSERT_TAIL(&(csv->records), rec, next_record);
|
||||||
csv->num_recs++;
|
csv->num_recs++;
|
||||||
|
@ -557,10 +557,11 @@ prefix_list_entry_delete (struct prefix_list *plist,
|
|||||||
struct prefix_list_entry *pentry,
|
struct prefix_list_entry *pentry,
|
||||||
int update_list)
|
int update_list)
|
||||||
{
|
{
|
||||||
prefix_list_trie_del (plist, pentry);
|
|
||||||
|
|
||||||
if (plist == NULL || pentry == NULL)
|
if (plist == NULL || pentry == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
prefix_list_trie_del (plist, pentry);
|
||||||
|
|
||||||
if (pentry->prev)
|
if (pentry->prev)
|
||||||
pentry->prev->next = pentry->next;
|
pentry->prev->next = pentry->next;
|
||||||
else
|
else
|
||||||
|
14
lib/prefix.c
14
lib/prefix.c
@ -722,20 +722,6 @@ apply_mask_ipv6 (struct prefix_ipv6 *p)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
str2in6_addr (const char *str, struct in6_addr *addr)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
unsigned int x;
|
|
||||||
|
|
||||||
/* %x must point to unsinged int */
|
|
||||||
for (i = 0; i < 16; i++)
|
|
||||||
{
|
|
||||||
sscanf (str + (i * 2), "%02x", &x);
|
|
||||||
addr->s6_addr[i] = x & 0xff;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
apply_mask (struct prefix *p)
|
apply_mask (struct prefix *p)
|
||||||
{
|
{
|
||||||
|
@ -281,7 +281,6 @@ extern void apply_mask_ipv6 (struct prefix_ipv6 *);
|
|||||||
extern int ip6_masklen (struct in6_addr);
|
extern int ip6_masklen (struct in6_addr);
|
||||||
extern void masklen2ip6 (const int, struct in6_addr *);
|
extern void masklen2ip6 (const int, struct in6_addr *);
|
||||||
|
|
||||||
extern void str2in6_addr (const char *, struct in6_addr *);
|
|
||||||
extern const char *inet6_ntoa (struct in6_addr);
|
extern const char *inet6_ntoa (struct in6_addr);
|
||||||
|
|
||||||
static inline int ipv6_martian (struct in6_addr *addr)
|
static inline int ipv6_martian (struct in6_addr *addr)
|
||||||
|
@ -800,29 +800,29 @@ route_map_free_map (struct route_map *map)
|
|||||||
struct route_map_list *list;
|
struct route_map_list *list;
|
||||||
struct route_map_index *index;
|
struct route_map_index *index;
|
||||||
|
|
||||||
|
if (map == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
while ((index = map->head) != NULL)
|
while ((index = map->head) != NULL)
|
||||||
route_map_index_delete (index, 0);
|
route_map_index_delete (index, 0);
|
||||||
|
|
||||||
list = &route_map_master;
|
list = &route_map_master;
|
||||||
|
|
||||||
if (map != NULL)
|
QOBJ_UNREG (map);
|
||||||
{
|
|
||||||
QOBJ_UNREG (map);
|
|
||||||
|
|
||||||
if (map->next)
|
if (map->next)
|
||||||
map->next->prev = map->prev;
|
map->next->prev = map->prev;
|
||||||
else
|
else
|
||||||
list->tail = map->prev;
|
list->tail = map->prev;
|
||||||
|
|
||||||
if (map->prev)
|
if (map->prev)
|
||||||
map->prev->next = map->next;
|
map->prev->next = map->next;
|
||||||
else
|
else
|
||||||
list->head = map->next;
|
list->head = map->next;
|
||||||
|
|
||||||
hash_release(route_map_master_hash, map);
|
hash_release(route_map_master_hash, map);
|
||||||
XFREE (MTYPE_ROUTE_MAP_NAME, map->name);
|
XFREE (MTYPE_ROUTE_MAP_NAME, map->name);
|
||||||
XFREE (MTYPE_ROUTE_MAP, map);
|
XFREE (MTYPE_ROUTE_MAP, map);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Route map delete from list. */
|
/* Route map delete from list. */
|
||||||
@ -1053,7 +1053,7 @@ vty_show_route_map (struct vty *vty, const char *name)
|
|||||||
{
|
{
|
||||||
if (zlog_default)
|
if (zlog_default)
|
||||||
vty_out (vty, "%s", zlog_proto_names[zlog_default->protocol]);
|
vty_out (vty, "%s", zlog_proto_names[zlog_default->protocol]);
|
||||||
if (zlog_default->instance)
|
if (zlog_default && zlog_default->instance)
|
||||||
vty_out (vty, " %d", zlog_default->instance);
|
vty_out (vty, " %d", zlog_default->instance);
|
||||||
vty_out (vty, ": 'route-map %s' not found%s", name, VTY_NEWLINE);
|
vty_out (vty, ": 'route-map %s' not found%s", name, VTY_NEWLINE);
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
|
Loading…
Reference in New Issue
Block a user