mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-04-28 21:20:48 +00:00
ospfclient: condition optimization
Its better to check the length and then the type of the LSA Signed-off-by: sri-mohan1 <sri.mohan@samsung.com>
This commit is contained in:
parent
594936dd0a
commit
ac62d9fdca
@ -439,6 +439,12 @@ int ospf_apiclient_lsa_originate(struct ospf_apiclient *oclient,
|
||||
struct lsa_header *lsah;
|
||||
uint32_t tmp;
|
||||
|
||||
/* Validate opaque LSA length */
|
||||
if ((size_t)opaquelen > sizeof(buf) - sizeof(struct lsa_header)) {
|
||||
fprintf(stderr, "opaquelen(%d) is larger than buf size %zu\n",
|
||||
opaquelen, sizeof(buf));
|
||||
return OSPF_API_NOMEMORY;
|
||||
}
|
||||
|
||||
/* We can only originate opaque LSAs */
|
||||
if (!IS_OPAQUE_LSA(lsa_type)) {
|
||||
@ -447,12 +453,6 @@ int ospf_apiclient_lsa_originate(struct ospf_apiclient *oclient,
|
||||
return OSPF_API_ILLEGALLSATYPE;
|
||||
}
|
||||
|
||||
if ((size_t)opaquelen > sizeof(buf) - sizeof(struct lsa_header)) {
|
||||
fprintf(stderr, "opaquelen(%d) is larger than buf size %zu\n",
|
||||
opaquelen, sizeof(buf));
|
||||
return OSPF_API_NOMEMORY;
|
||||
}
|
||||
|
||||
/* Make a new LSA from parameters */
|
||||
lsah = (struct lsa_header *)buf;
|
||||
lsah->ls_age = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user