42 lines
1.1 KiB
Diff
42 lines
1.1 KiB
Diff
From 748b44354889329f8c0ef0b9c86013a80f195be2 Mon Sep 17 00:00:00 2001
|
|
From: Zhifeng, Cai <bluewindow@h3c.com>
|
|
Date: Sun, 6 Mar 2011 21:39:10 -0800
|
|
Subject: [PATCH 23/51] lldpad: malloc could fail in clif_attach_helper()
|
|
|
|
malloc() may fail in clif_attach_helper() so return
|
|
values must be checked.
|
|
|
|
Suggested-By: Zhifeng, Cai <bluewindow@h3c.com>
|
|
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
|
|
Signed-off-by: Petr Sabata <psabata@redhat.com>
|
|
---
|
|
clif.c | 6 ++++++
|
|
1 files changed, 6 insertions(+), 0 deletions(-)
|
|
|
|
diff --git a/clif.c b/clif.c
|
|
index 20885f6..9e256f2 100644
|
|
--- a/clif.c
|
|
+++ b/clif.c
|
|
@@ -165,12 +165,18 @@ static int clif_attach_helper(struct clif *clif, char *tlvs_hex, int attach)
|
|
/* Allocate maximum buffer usage */
|
|
if (tlvs_hex && attach) {
|
|
buf = malloc(sizeof(char)*(strlen(tlvs_hex) + 1));
|
|
+ if (!buf)
|
|
+ return -1;
|
|
sprintf(buf, "%s%s","A",tlvs_hex);
|
|
} else if (attach) {
|
|
buf = malloc(sizeof(char) * 2);
|
|
+ if (!buf)
|
|
+ return -1;
|
|
sprintf(buf, "A");
|
|
} else {
|
|
buf = malloc(sizeof(char) * 2);
|
|
+ if (!buf)
|
|
+ return -1;
|
|
sprintf(buf, "D");
|
|
}
|
|
|
|
--
|
|
1.7.4.4
|
|
|