summaryrefslogtreecommitdiff
path: root/ospfclient
diff options
context:
space:
mode:
Diffstat (limited to 'ospfclient')
-rw-r--r--ospfclient/ospf_apiclient.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/ospfclient/ospf_apiclient.c b/ospfclient/ospf_apiclient.c
index 41f0b25b91..b5e6389d4c 100644
--- a/ospfclient/ospf_apiclient.c
+++ b/ospfclient/ospf_apiclient.c
@@ -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;