From 868d075a9f580bb38b7a634e1a92d01fc9a4ca53 Mon Sep 17 00:00:00 2001 From: Florian Schmidt Date: Thu, 21 Apr 2016 14:30:38 +0200 Subject: [PATCH] Fix null pointer derefence in non-debug builds xenbus_get_self_id() calls xenbus_read within BUG_ON, but BUG_ON(x) resolves to nothing in non-debug builds, removing the call. This made sscanf dereference a null value. --- xenbus/xenbus.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xenbus/xenbus.c b/xenbus/xenbus.c index f74ed58..fccd1af 100644 --- a/xenbus/xenbus.c +++ b/xenbus/xenbus.c @@ -833,7 +833,9 @@ domid_t xenbus_get_self_id(void) char *dom_id; domid_t ret; - BUG_ON(xenbus_read(XBT_NIL, "domid", &dom_id)); + if (xenbus_read(XBT_NIL, "domid", &dom_id)) { + BUG_ON(1); + } sscanf(dom_id, "%"SCNd16, &ret); return ret;