OSDN Git Service

[COVERITY] Fix bad error checking for NULL parameter in ss library
authorBrian Behlendorf <behlendorf1@llnl.gov>
Mon, 19 Mar 2007 12:39:32 +0000 (08:39 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 19 Mar 2007 12:39:32 +0000 (08:39 -0400)
Looks like flawed reasoning.  Here if info_dir is NULL then you are
guaranteed to blow up since you will dereference it.  It seems like the
correct thing to do here (what the code author meant to do) was to set
*code_ptr = SS_ET_NO_INFO_DIR if info_dir was NULL or if *info_dir was
an empty string (aka *info_dir == '\0').

Coverity ID: 8: Forward Null

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
lib/ss/ChangeLog
lib/ss/help.c

index 906ff46..1bb4272 100644 (file)
@@ -1,3 +1,8 @@
+2007-03-19  Theodore Tso  <tytso@mit.edu>
+
+       * help.c (ss_add_info_dir): Fix error checking for NULL parameter
+               passed via info_dir.
+
 2006-11-17  Theodore Tso  <tytso@mit.edu>
 
        * get_readline.c (DEFAULT_LIBPATH): Add libreadline.so.5 to the
index 235633f..c1a167d 100644 (file)
@@ -138,7 +138,7 @@ void ss_add_info_dir(sci_idx, info_dir, code_ptr)
     register char **dirs;
 
     info = ss_info(sci_idx);
-    if (info_dir == NULL && *info_dir) {
+    if (info_dir == NULL || *info_dir == '\0') {
        *code_ptr = SS_ET_NO_INFO_DIR;
        return;
     }