server: exportname cannot be NULL.
commitfee1e8b131b5992fc6ee005034fd3c063d6df0c3
authorRichard W.M. Jones <rjones@redhat.com>
Fri, 8 Nov 2019 18:25:10 +0000 (8 18:25 +0000)
committerRichard W.M. Jones <rjones@redhat.com>
Fri, 8 Nov 2019 18:25:10 +0000 (8 18:25 +0000)
tree516184eed72f581158890106a7a76732d1d7d4e4
parent78f89ffb81e81002d43198b3ccb6b19b3801966d
server: exportname cannot be NULL.

The fix is to only add exportname to the URI if it's not "" (rather
than not NULL, because it cannot be NULL).

 Error: FORWARD_NULL (CWE-476): [#def30]
 nbdkit-1.15.7/server/captive.c:74: var_compare_op: Comparing "exportname" to null implies that "exportname" might be null.
 nbdkit-1.15.7/server/captive.c:92: var_deref_model: Passing null pointer "exportname" to "shell_quote", which dereferences it.
 #   90|     /* Expose $exportname. */
 #   91|     fprintf (fp, "exportname=");
 #   92|->   shell_quote (exportname, fp);
 #   93|     putc ('\n', fp);
 #   94|

Bug found by Coverity.
server/captive.c