libxc: fix a Segmentation fault
PATCH 1/1 libxc: fix a Segmentation fault
# xl list xc: error: Could not obtain handle on privileged command interface (2 = No such file or directory): Internal error Segmentation fault
This is because xc free the logger which xl created.
tools/libxc/xc_private.c +3 -1
@@ -19,6 +19,7 @@ xentoollog_logger *dombuild_logger, unsigned open_flags) {xc_interface xch_buf, *xch = &xch_buf; +int init_handler =0 ; xch->fd =-1 ; xch->dombuild_logger_file =0 ;
@@ -33,6 +34,7 @@xtl_createlogger_stdiostream (stderr,XTL_PROGRESS ,0 );if (!xch->error_handler) goto err; + init_handler =1 ; } xch =malloc (sizeof (*xch));
@@ -52,7 +54,7 @@return xch; err: -if (xch)xtl_logger_destroy (xch->error_handler); +if (xch && init_handler)xtl_logger_destroy (xch->error_handler);if (xch != &xch_buf)free (xch);return 0 ; }
Signature · 2 lines
Regards Yang Hongyang
Yang Hongyang writes ("[Xen-devel] [PATCH]libxc: fix a Segmentation fault"):
Quoted 5 lines
# xl list xc: error: Could not obtain handle on privileged command interface (2 = No such file or directory): Internal error Segmentation faultThis is because xc free the logger which xl created.
Well spotted. You're right about the cause, but your fix is not correct. The correct fix is that xc_interface_open's error path should free error_handler_tofree rather than error_handler. So there is no need to add another variable. I will apply that fix.
Thanks,
Ian.
Quoted 5 lines · Ian Jackson
Yang Hongyang writes ("[Xen-devel] [PATCH]libxc: fix a Segmentation fault"):
Quoted 4 lines
# xl list xc: error: Could not obtain handle on privileged command interface (2 = No such file or directory): Internal error Segmentation fault
Quoted 7 lines
Quoted 1 line
This is because xc free the logger which xl created.
Well spotted. You're right about the cause, but your fix is not correct. The correct fix is that xc_interface_open's error path should free
error_handler_tofreerather thanerror_handler. So there is no need to add another variable. I will apply that fix.
OK,Thanks Ian.
Quoted 4 lines
Thanks,
Ian.
Signature · 2 lines
Regards Yang Hongyang