Better check of return values from app_isdir and app_access
authorRichard Levitte <levitte@openssl.org>
Fri, 20 Apr 2018 10:27:14 +0000 (12:27 +0200)
committerRichard Levitte <levitte@openssl.org>
Wed, 25 Apr 2018 09:44:26 +0000 (11:44 +0200)
[extended tests]

Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/6033)

apps/opt.c

index a9d163a4805b9575ee0f626105555bed1e93f857..4d06983241c852c1911c938204a8be56c9474d1a 100644 (file)
@@ -676,13 +676,13 @@ int opt_next(void)
             /* Just a string. */
             break;
         case '/':
-            if (app_isdir(arg) >= 0)
+            if (app_isdir(arg) > 0)
                 break;
             BIO_printf(bio_err, "%s: Not a directory: %s\n", prog, arg);
             return -1;
         case '<':
             /* Input file. */
-            if (strcmp(arg, "-") == 0 || app_access(arg, R_OK) >= 0)
+            if (strcmp(arg, "-") == 0 || app_access(arg, R_OK) == 0)
                 break;
             BIO_printf(bio_err,
                        "%s: Cannot open input file %s, %s\n",
@@ -690,7 +690,7 @@ int opt_next(void)
             return -1;
         case '>':
             /* Output file. */
-            if (strcmp(arg, "-") == 0 || app_access(arg, W_OK) >= 0 || errno == ENOENT)
+            if (strcmp(arg, "-") == 0 || app_access(arg, W_OK) == 0 || errno == ENOENT)
                 break;
             BIO_printf(bio_err,
                        "%s: Cannot open output file %s, %s\n",