Skip to contentSkip to conversation

tools/mfndump: Avoid deliberate NULL dereference

PATCH Superseded Andrew Cooper 4 participants 5 messages Mar 12, 2014 – Mar 13, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools/mfndump: Avoid deliberate NULL dereference

If we failed to open an xc interface, using xch to log an error will end in tears. Print to stderr instead, as we are bailing immediately later.

Coverity-id: 1191885
CC: Ian Campbell <[email protected]>
CC: Ian Jackson <[email protected]>
CC: Dario Faggioli <[email protected]>

---

This is why macros depending on variables in scope, particularly ones named as simily as "ERROR", are evil.

---
 tools/misc/xen-mfndump.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/misc/xen-mfndump.c +1 -1
index 8064527..e1ea536 100644
@@ -400,7 +400,7 @@ int main(int argc, char *argv[])
     xch = xc_interface_open(0, 0, 0);
     if ( !xch )
     {
-        ERROR("Failed to open an xc handler");
+        fprintf(stderr, "Failed to open an xc handler");
         return 1;
     }
 
Signature · 1 line
1.7.10.4
Acked-by on v1 1/1
#1 lore raw

On Wed, 2014-03-12 at 21:04 +0000, Andrew Cooper wrote:

"deliberate" doesn't seem likely. "unintentional" is more plausible

Quoted 5 lines

If we failed to open an xc interface, using xch to log an error will end in tears. Print to stderr instead, as we are bailing immediately later.

Coverity-id: 1191885

Quoted 24 lines
CC Ian Jackson <[email protected]>
CC Dario Faggioli <[email protected]>

---

This is why macros depending on variables in scope, particularly ones named as simily as "ERROR", are evil.

---
 tools/misc/xen-mfndump.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/misc/xen-mfndump.c +1 -1
index 8064527..e1ea536 100644
@@ -400,7 +400,7 @@ int main(int argc, char *argv[])
     xch = xc_interface_open(0, 0, 0);
     if ( !xch )
     {
-        ERROR("Failed to open an xc handler");
+        fprintf(stderr, "Failed to open an xc handler");
         return 1;
     }
 
#2 lore raw

PATCH v2 1/1 tools/mfndump: Avoid unintentional NULL dereference

If we failed to open an xc interface, using xch to log an error will end in tears. Print to stderr instead, as we are bailing immediately later.

Coverity-id: 1191885

CC Ian Jackson <[email protected]>
CC Dario Faggioli <[email protected]>

---

v2: Reword subject

This is why macros depending on variables in scope, particularly ones named as simily as "ERROR", are evil.

---
 tools/misc/xen-mfndump.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/misc/xen-mfndump.c +1 -1
index 8064527..e1ea536 100644
@@ -400,7 +400,7 @@ int main(int argc, char *argv[])
     xch = xc_interface_open(0, 0, 0);
     if ( !xch )
     {
-        ERROR("Failed to open an xc handler");
+        fprintf(stderr, "Failed to open an xc handler");
         return 1;
     }
 
Signature · 1 line
1.7.10.4
Acked-by on v2 1/1
#3 lore raw

Re: [PATCH v2] tools/mfndump: Avoid unintentional NULL dereference

Quoted 9 lines · Andrew Cooper

If we failed to open an xc interface, using xch to log an error will end in tears. Print to stderr instead, as we are bailing immediately later.

Coverity-id: 1191885

CC Ian Jackson <[email protected]>
CC Dario Faggioli <[email protected]>

If this is not yet in, feel free to add:

Because, I confirm, I did unintentionally and not deliberately! :-P

Quoted 5 lines

v2: Reword subject

This is why macros depending on variables in scope, particularly ones named as simily as "ERROR", are evil.

I Could not agree more!

Regards,
Dario

Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#4 lore raw

Re: [PATCH v2] tools/mfndump: Avoid unintentional NULL dereference

Dario Faggioli writes ("Re: [PATCH v2] tools/mfndump: Avoid unintentional NULL dereference"):

Quoted 10 lines · Andrew Cooper
Quoted 9 lines

If we failed to open an xc interface, using xch to log an error will end in tears. Print to stderr instead, as we are bailing immediately later.

Coverity-id: 1191885

CC Ian Jackson <[email protected]>
CC Dario Faggioli <[email protected]>
Quoted 3 lines

If this is not yet in, feel free to add:

Thanks everyone.

Ian.