Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 14 Jun 2021 20:25:03 GMT
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 4e30dd0567da - stable/12 - ngatm: Handle errors from uni_msg_extend()
Message-ID:  <202106142025.15EKP3Zm072954@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/12 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=4e30dd0567da0ce7e34d9a3438e978465584b161

commit 4e30dd0567da0ce7e34d9a3438e978465584b161
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2021-06-06 20:42:16 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2021-06-14 20:24:48 +0000

    ngatm: Handle errors from uni_msg_extend()
    
    uni_msg_extend() may fail due to a memory allocation failure.  In this
    case, though, the message is freed, so callers shouldn't touch it.
    
    PR:             255861
    Reviewed by:    harti
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit e755e2776ddff729ae4102f3273473aa33b00077)
---
 sys/contrib/ngatm/netnatm/msg/uni_ie.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/sys/contrib/ngatm/netnatm/msg/uni_ie.c b/sys/contrib/ngatm/netnatm/msg/uni_ie.c
index e4b8310d88d9..3842279c63a1 100644
--- a/sys/contrib/ngatm/netnatm/msg/uni_ie.c
+++ b/sys/contrib/ngatm/netnatm/msg/uni_ie.c
@@ -216,7 +216,8 @@ uni_encode_msg_hdr(struct uni_msg *msg, struct uni_msghdr *h,
 {
 	u_char byte;
 
-	(void)uni_msg_ensure(msg, 9);
+	if (uni_msg_ensure(msg, 9) != 0)
+		return -1;
 
 	APP_BYTE(msg, cx->pnni ? PNNI_PROTO : UNI_PROTO); 
 	APP_BYTE(msg, 3); 
@@ -654,7 +655,8 @@ uni_encode_ie_hdr(struct uni_msg *msg, enum uni_ietype type,
 {
 	u_char byte;
 
-	(void)uni_msg_ensure(msg, 4 + len);
+	if (uni_msg_ensure(msg, 4 + len) != 0)
+		return -1;
 	*msg->b_wptr++ = type;
 
 	byte = 0x80 | (h->coding << 5);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202106142025.15EKP3Zm072954>