[libvirt] [PATCH 0/2] NULL string fixes

Peter Krempa (2): maint: Change the text of the NULLSTR() macro to "<null>" qemu: blockjob: Print correct file name in error message src/internal.h | 2 +- src/qemu/qemu_driver.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) -- 1.8.5.3

Eric Blake suggested to change this message to be different from the glibc's NULL deref protection message in printf to be able to differentiate errors. --- src/internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/internal.h b/src/internal.h index 4ba0e41..cef3da0 100644 --- a/src/internal.h +++ b/src/internal.h @@ -244,7 +244,7 @@ /* * Use this when passing possibly-NULL strings to printf-a-likes. */ -# define NULLSTR(s) ((s) ? (s) : "(null)") +# define NULLSTR(s) ((s) ? (s) : "<null>") /** * TODO: -- 1.8.5.3

On 02/05/2014 10:44 AM, Peter Krempa wrote:
Eric Blake suggested to change this message to be different from the glibc's NULL deref protection message in printf to be able to differentiate errors. --- src/internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
ACK (although I'm probably biased) - that way, if we see "<null>" in a message, we know we are safe; if we see "(null)" in a message, we know we have a NULL deref bug to fix.
diff --git a/src/internal.h b/src/internal.h index 4ba0e41..cef3da0 100644 --- a/src/internal.h +++ b/src/internal.h @@ -244,7 +244,7 @@ /* * Use this when passing possibly-NULL strings to printf-a-likes. */ -# define NULLSTR(s) ((s) ? (s) : "(null)") +# define NULLSTR(s) ((s) ? (s) : "<null>")
/** * TODO:
-- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

When attempting a blockcommit from the top layer, the base argument passed is NULL. This will be dereferenced when attempting a commit with an empty image chain. Output the real volume path instead: virsh blockcommit --verbose --path vda --domain DOMNAME --wait error: invalid argument: top '/path/somefile' in chain for 'vda' has no backing file instead of: error: invalid argument: top '(null)' in chain for 'vda' has no backing file --- src/qemu/qemu_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 38a48db..8998201 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15180,7 +15180,7 @@ qemuDomainBlockCommit(virDomainPtr dom, const char *path, const char *base, if (!top_meta || !top_meta->backingStore) { virReportError(VIR_ERR_INVALID_ARG, _("top '%s' in chain for '%s' has no backing file"), - top, path); + top_canon, path); goto endjob; } if (!base && (flags & VIR_DOMAIN_BLOCK_COMMIT_SHALLOW)) { -- 1.8.5.3

On 02/05/2014 10:44 AM, Peter Krempa wrote:
When attempting a blockcommit from the top layer, the base argument passed is NULL. This will be dereferenced when attempting a commit with an empty image chain. Output the real volume path instead:
virsh blockcommit --verbose --path vda --domain DOMNAME --wait error: invalid argument: top '/path/somefile' in chain for 'vda' has no backing file
instead of:
error: invalid argument: top '(null)' in chain for 'vda' has no backing file --- src/qemu/qemu_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
ACK
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 38a48db..8998201 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15180,7 +15180,7 @@ qemuDomainBlockCommit(virDomainPtr dom, const char *path, const char *base, if (!top_meta || !top_meta->backingStore) { virReportError(VIR_ERR_INVALID_ARG, _("top '%s' in chain for '%s' has no backing file"), - top, path); + top_canon, path); goto endjob; } if (!base && (flags & VIR_DOMAIN_BLOCK_COMMIT_SHALLOW)) {
-- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 02/05/14 19:41, Eric Blake wrote:
On 02/05/2014 10:44 AM, Peter Krempa wrote:
When attempting a blockcommit from the top layer, the base argument passed is NULL. This will be dereferenced when attempting a commit with an empty image chain. Output the real volume path instead:
virsh blockcommit --verbose --path vda --domain DOMNAME --wait error: invalid argument: top '/path/somefile' in chain for 'vda' has no backing file
instead of:
error: invalid argument: top '(null)' in chain for 'vda' has no backing file --- src/qemu/qemu_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
ACK
Series is now pushed. Thanks. Peter
participants (2)
-
Eric Blake
-
Peter Krempa