Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential buffer overflow in ospf_apiclient_lsa_originate #11602

Closed
yiyuaner opened this issue Jul 14, 2022 · 0 comments
Closed

Potential buffer overflow in ospf_apiclient_lsa_originate #11602

yiyuaner opened this issue Jul 14, 2022 · 0 comments
Labels
triage Needs further investigation

Comments

@yiyuaner
Copy link

In the file ospfclient/ospf_apiclient.c, the function ospf_apiclient_lsa_originate has the following code:

int ospf_apiclient_lsa_originate(struct ospf_apiclient *oclient,
				 struct in_addr ifaddr, struct in_addr area_id,
				 uint8_t lsa_type, uint8_t opaque_type,
				 uint32_t opaque_id, void *opaquedata,
				 int opaquelen) {
    uint8_t buf[OSPF_MAX_LSA_SIZE];
    struct lsa_header *lsah;
    ...
    lsah = (struct lsa_header *)buf;
    ...
    memcpy(((uint8_t *)lsah) + sizeof(struct lsa_header), opaquedata,
	       opaquelen);
}

When passing a large value for opaquelen, the memcpy can cause a buffer overflow to buf. I think even if this api is intended to be used internally, it is still better to check that copy from opaquedata will not overflow buf.

@yiyuaner yiyuaner added the triage Needs further investigation label Jul 14, 2022
donaldsharp added a commit to donaldsharp/frr that referenced this issue Jul 21, 2022
…te into stack

Even though OSPF_MAX_LSA_SIZE is quite large and holds the upper bound
on what can be written into a lsa, let's add a small check to ensure
it is not possible to do a bad thing.

This wins one of the long standing bug awards.  2003!

Fixes: FRRouting#11602
Signed-off-by: Donald Sharp <[email protected]>
donaldsharp added a commit to donaldsharp/frr that referenced this issue Jul 22, 2022
…te into stack

Even though OSPF_MAX_LSA_SIZE is quite large and holds the upper bound
on what can be written into a lsa, let's add a small check to ensure
it is not possible to do a bad thing.

This wins one of the long standing bug awards.  2003!

Fixes: FRRouting#11602
Signed-off-by: Donald Sharp <[email protected]>
mergify bot pushed a commit that referenced this issue Oct 7, 2022
…te into stack

Even though OSPF_MAX_LSA_SIZE is quite large and holds the upper bound
on what can be written into a lsa, let's add a small check to ensure
it is not possible to do a bad thing.

This wins one of the long standing bug awards.  2003!

Fixes: #11602
Signed-off-by: Donald Sharp <[email protected]>
(cherry picked from commit d2aeac3)
mergify bot pushed a commit that referenced this issue Oct 7, 2022
…te into stack

Even though OSPF_MAX_LSA_SIZE is quite large and holds the upper bound
on what can be written into a lsa, let's add a small check to ensure
it is not possible to do a bad thing.

This wins one of the long standing bug awards.  2003!

Fixes: #11602
Signed-off-by: Donald Sharp <[email protected]>
(cherry picked from commit d2aeac3)
mergify bot pushed a commit that referenced this issue Oct 7, 2022
…te into stack

Even though OSPF_MAX_LSA_SIZE is quite large and holds the upper bound
on what can be written into a lsa, let's add a small check to ensure
it is not possible to do a bad thing.

This wins one of the long standing bug awards.  2003!

Fixes: #11602
Signed-off-by: Donald Sharp <[email protected]>
(cherry picked from commit d2aeac3)
donaldsharp added a commit to donaldsharp/frr that referenced this issue Oct 10, 2022
…te into stack

Even though OSPF_MAX_LSA_SIZE is quite large and holds the upper bound
on what can be written into a lsa, let's add a small check to ensure
it is not possible to do a bad thing.

This wins one of the long standing bug awards.  2003!

Fixes: FRRouting#11602
Signed-off-by: Donald Sharp <[email protected]>
polychaeta pushed a commit that referenced this issue Oct 11, 2022
…te into stack

Even though OSPF_MAX_LSA_SIZE is quite large and holds the upper bound
on what can be written into a lsa, let's add a small check to ensure
it is not possible to do a bad thing.

This wins one of the long standing bug awards.  2003!

Fixes: #11602
Signed-off-by: Donald Sharp <[email protected]>
(cherry picked from commit d2aeac3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage Needs further investigation
Projects
None yet
Development

No branches or pull requests

1 participant