0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-09-19 11:55:21 +00:00

OSPF: variable-length array of size 0 replaced by alloca()'d pointer

NULL pointer is safer than a random pointer onto stack if this function
gets changed and eventually broken.
This commit is contained in:
Maria Matejka 2019-08-16 12:47:13 +02:00
parent 05b8620a81
commit 051f258cad

View File

@ -1289,7 +1289,7 @@ ospf_sh_state(struct proto *P, int verbose, int reachable)
uint num = p->gr->hash_entries;
struct top_hash_entry *hea[num];
struct top_hash_entry *hex[verbose ? num : 0];
struct top_hash_entry **hex = verbose ? alloca(num * sizeof(struct top_hash_entry *)) : NULL;
struct top_hash_entry *he;
struct top_hash_entry *cnode = NULL;
@ -1334,7 +1334,9 @@ ospf_sh_state(struct proto *P, int verbose, int reachable)
lsa_compare_ospf3 = !ospf2;
qsort(hea, j1, sizeof(struct top_hash_entry *), lsa_compare_for_state);
qsort(hex, jx, sizeof(struct top_hash_entry *), ext_compare_for_state);
if (verbose)
qsort(hex, jx, sizeof(struct top_hash_entry *), ext_compare_for_state);
/*
* This code is a bit tricky, we have a primary LSAs (router and