On Wed, 12 Aug 2015, Morgan Stewart wrote:
Coverity Scan #1221454
In zebra/interface.c if_data could be null dereferenced without early
check. Added if/else block to catch the problem before errors.
Signed-off-by: Morgan Stewart <[email protected]>
---
zebra/interface.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/zebra/interface.c b/zebra/interface.c
index 14c3e78..b4ac9ad 100644
--- a/zebra/interface.c
+++ b/zebra/interface.c
@@ -368,10 +368,15 @@ if_add_update (struct interface *ifp)
struct zebra_if *if_data;
if_data = ifp->info;
- if (if_data->multicast == IF_ZEBRA_MULTICAST_ON)
- if_set_flags (ifp, IFF_MULTICAST);
- else if (if_data->multicast == IF_ZEBRA_MULTICAST_OFF)
- if_unset_flags (ifp, IFF_MULTICAST);
+ if (if_data)
+ {
+ if (if_data->multicast == IF_ZEBRA_MULTICAST_ON)
+ if_set_flags (ifp, IFF_MULTICAST);
+ else if (if_data->multicast == IF_ZEBRA_MULTICAST_OFF)
+ if_unset_flags (ifp, IFF_MULTICAST);
+ }
+ else
+ zlog_debug("Interface %s without info pointer, probably not a sane state.",
ifp->name);
zebra_interface_add_update (ifp);
Should this fall a bit harder than a zlog_debug?
"interface must have an info pointer" is part of the contract here
clearly. And it should generally have one as zebra_if is called as a
new-hook.
Do we need to add code to soft-fail at run-time for cases that should
never happen? I know everyone hates a runtime assert(), but I don't know
how to make this hard-fail at compile time. :(
regards,
--
Paul Jakma [email protected] @pjakma Key ID: 64A2FF6A
Fortune:
The three questions of greatest concern are -- 1. Is it attractive?
2. Is it amusing? 3. Does it know its place?
-- Fran Lebowitz, "Metropolitan Life"
_______________________________________________
Quagga-dev mailing list
[email protected]
https://lists.quagga.net/mailman/listinfo/quagga-dev