mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-05-29 09:44:26 +00:00
Merge pull request #2542 from pacovn/Coverity_1452552_Out-of-bounds_access
isisd: out-of-bounds access (Coverity 1452552)
This commit is contained in:
commit
dec20a1570
@ -77,14 +77,13 @@ enum vertextype {
|
|||||||
/*
|
/*
|
||||||
* Triple <N, d(N), {Adj(N)}>
|
* Triple <N, d(N), {Adj(N)}>
|
||||||
*/
|
*/
|
||||||
|
union isis_N {
|
||||||
|
uint8_t id[ISIS_SYS_ID_LEN + 1];
|
||||||
|
struct prefix prefix;
|
||||||
|
};
|
||||||
struct isis_vertex {
|
struct isis_vertex {
|
||||||
enum vertextype type;
|
enum vertextype type;
|
||||||
|
union isis_N N;
|
||||||
union {
|
|
||||||
uint8_t id[ISIS_SYS_ID_LEN + 1];
|
|
||||||
struct prefix prefix;
|
|
||||||
} N;
|
|
||||||
|
|
||||||
uint32_t d_N; /* d(N) Distance from this IS */
|
uint32_t d_N; /* d(N) Distance from this IS */
|
||||||
uint16_t depth; /* The depth in the imaginary tree */
|
uint16_t depth; /* The depth in the imaginary tree */
|
||||||
struct list *Adj_N; /* {Adj(N)} next hop or neighbor list */
|
struct list *Adj_N; /* {Adj(N)} next hop or neighbor list */
|
||||||
@ -407,28 +406,28 @@ static const char *vid2string(struct isis_vertex *vertex, char *buff, int size)
|
|||||||
return "UNKNOWN";
|
return "UNKNOWN";
|
||||||
}
|
}
|
||||||
|
|
||||||
static void isis_vertex_id_init(struct isis_vertex *vertex, void *id,
|
static void isis_vertex_id_init(struct isis_vertex *vertex, union isis_N *n,
|
||||||
enum vertextype vtype)
|
enum vertextype vtype)
|
||||||
{
|
{
|
||||||
vertex->type = vtype;
|
vertex->type = vtype;
|
||||||
|
|
||||||
if (VTYPE_IS(vtype) || VTYPE_ES(vtype)) {
|
if (VTYPE_IS(vtype) || VTYPE_ES(vtype)) {
|
||||||
memcpy(vertex->N.id, (uint8_t *)id, ISIS_SYS_ID_LEN + 1);
|
memcpy(vertex->N.id, n->id, ISIS_SYS_ID_LEN + 1);
|
||||||
} else if (VTYPE_IP(vtype)) {
|
} else if (VTYPE_IP(vtype)) {
|
||||||
memcpy(&vertex->N.prefix, (struct prefix *)id,
|
memcpy(&vertex->N.prefix, &n->prefix, sizeof(struct prefix));
|
||||||
sizeof(struct prefix));
|
|
||||||
} else {
|
} else {
|
||||||
zlog_err("WTF!");
|
zlog_err("WTF!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct isis_vertex *isis_vertex_new(void *id, enum vertextype vtype)
|
static struct isis_vertex *isis_vertex_new(union isis_N *n,
|
||||||
|
enum vertextype vtype)
|
||||||
{
|
{
|
||||||
struct isis_vertex *vertex;
|
struct isis_vertex *vertex;
|
||||||
|
|
||||||
vertex = XCALLOC(MTYPE_ISIS_VERTEX, sizeof(struct isis_vertex));
|
vertex = XCALLOC(MTYPE_ISIS_VERTEX, sizeof(struct isis_vertex));
|
||||||
|
|
||||||
isis_vertex_id_init(vertex, id, vtype);
|
isis_vertex_id_init(vertex, n, vtype);
|
||||||
|
|
||||||
vertex->Adj_N = list_new();
|
vertex->Adj_N = list_new();
|
||||||
vertex->parents = list_new();
|
vertex->parents = list_new();
|
||||||
@ -598,17 +597,17 @@ static struct isis_vertex *isis_spf_add_root(struct isis_spftree *spftree,
|
|||||||
#ifdef EXTREME_DEBUG
|
#ifdef EXTREME_DEBUG
|
||||||
char buff[PREFIX2STR_BUFFER];
|
char buff[PREFIX2STR_BUFFER];
|
||||||
#endif /* EXTREME_DEBUG */
|
#endif /* EXTREME_DEBUG */
|
||||||
uint8_t id[ISIS_SYS_ID_LEN + 1];
|
union isis_N n;
|
||||||
|
|
||||||
memcpy(id, sysid, ISIS_SYS_ID_LEN);
|
memcpy(n.id, sysid, ISIS_SYS_ID_LEN);
|
||||||
LSP_PSEUDO_ID(id) = 0;
|
LSP_PSEUDO_ID(n.id) = 0;
|
||||||
|
|
||||||
lsp = isis_root_system_lsp(spftree->area, spftree->level, sysid);
|
lsp = isis_root_system_lsp(spftree->area, spftree->level, sysid);
|
||||||
if (lsp == NULL)
|
if (lsp == NULL)
|
||||||
zlog_warn("ISIS-Spf: could not find own l%d LSP!",
|
zlog_warn("ISIS-Spf: could not find own l%d LSP!",
|
||||||
spftree->level);
|
spftree->level);
|
||||||
|
|
||||||
vertex = isis_vertex_new(id,
|
vertex = isis_vertex_new(&n,
|
||||||
spftree->area->oldmetric
|
spftree->area->oldmetric
|
||||||
? VTYPE_NONPSEUDO_IS
|
? VTYPE_NONPSEUDO_IS
|
||||||
: VTYPE_NONPSEUDO_TE_IS);
|
: VTYPE_NONPSEUDO_TE_IS);
|
||||||
@ -625,11 +624,12 @@ static struct isis_vertex *isis_spf_add_root(struct isis_spftree *spftree,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static struct isis_vertex *isis_find_vertex(struct isis_vertex_queue *queue,
|
static struct isis_vertex *isis_find_vertex(struct isis_vertex_queue *queue,
|
||||||
void *id, enum vertextype vtype)
|
union isis_N *n,
|
||||||
|
enum vertextype vtype)
|
||||||
{
|
{
|
||||||
struct isis_vertex querier;
|
struct isis_vertex querier;
|
||||||
|
|
||||||
isis_vertex_id_init(&querier, id, vtype);
|
isis_vertex_id_init(&querier, n, vtype);
|
||||||
return hash_lookup(queue->hash, &querier);
|
return hash_lookup(queue->hash, &querier);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1212,7 +1212,7 @@ static void add_to_paths(struct isis_spftree *spftree,
|
|||||||
{
|
{
|
||||||
char buff[PREFIX2STR_BUFFER];
|
char buff[PREFIX2STR_BUFFER];
|
||||||
|
|
||||||
if (isis_find_vertex(&spftree->paths, vertex->N.id, vertex->type))
|
if (isis_find_vertex(&spftree->paths, &vertex->N, vertex->type))
|
||||||
return;
|
return;
|
||||||
isis_vertex_queue_append(&spftree->paths, vertex);
|
isis_vertex_queue_append(&spftree->paths, vertex);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user