[dm-devel] [PATCH 4/9] multipathd: don't call strlen on NULL variables

Martin Wilck mwilck at suse.de
Thu Apr 13 14:12:43 UTC 2017


On Fri, 2017-04-07 at 01:16 -0500, Benjamin Marzinski wrote:
> strlen has undefined results when passed a NULL variable, so don't do
> it.
> 
> Signed-off-by: Benjamin Marzinski <bmarzins at redhat.com>
> ---

This is certainly correct. Yet I have two remarks: 

1) There are many more calls to strlen() in the multipath-tools code
which would need to be likewise protected.

2) If STRDUP("ok\n") returns NULL, we're likely to be so hosed that we
might as well call abort() anyway (which is a philosophy that I
personally quite like - multipathd is not such a vital part of the
system that it can't risk dying).

Regards
Martin




More information about the dm-devel mailing list