PR: 1937
authorDr. Stephen Henson <steve@openssl.org>
Tue, 2 Jun 2009 11:31:32 +0000 (11:31 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Tue, 2 Jun 2009 11:31:32 +0000 (11:31 +0000)
Submitted by: Mark Phalan <Mark.Phalan@Sun.COM>
Reviewed by: steve@openssl.org

Fix misuse of st_mode field in struct stat.

apps/ca.c
crypto/rand/randfile.c

index 68516ee9bd9ef4901ce4784fb42436bc1b0f1675..7bd229139ecc05c40ee59294436a63e4dbb9d58a 100644 (file)
--- a/apps/ca.c
+++ b/apps/ca.c
@@ -858,8 +858,8 @@ bad:
                        perror(outdir);
                        goto err;
                        }
-#ifdef S_IFDIR
-               if (!(sb.st_mode & S_IFDIR))
+#ifdef S_ISDIR
+               if (!S_ISDIR(sb.st_mode))
                        {
                        BIO_printf(bio_err,"%s need to be a directory\n",outdir);
                        perror(outdir);
index d108353bbc26366c4740b856e885781794333893..e12fe0b90c6cc89eb59a02de2976f67a67e52ff3 100644 (file)
@@ -127,8 +127,8 @@ int RAND_load_file(const char *file, long bytes)
        in=fopen(file,"rb");
 #endif
        if (in == NULL) goto err;
-#if defined(S_IFBLK) && defined(S_IFCHR)
-       if (sb.st_mode & (S_IFBLK | S_IFCHR)) {
+#if defined(S_ISBLK) && defined(S_ISCHR)
+       if (S_ISBLK(sb.st_mode) || S_ISCHR(sb.st_mode)) {
          /* this file is a device. we don't want read an infinite number
           * of bytes from a random device, nor do we want to use buffered
           * I/O because we will waste system entropy. 
@@ -174,8 +174,8 @@ int RAND_write_file(const char *file)
        
        i=stat(file,&sb);
        if (i != -1) { 
-#if defined(S_IFBLK) && defined(S_IFCHR)
-         if (sb.st_mode & (S_IFBLK | S_IFCHR)) {
+#if defined(S_ISBLK) && defined(S_ISCHR)
+         if (S_ISBLK(sb.st_mode) || S_ISCHR(sb.st_mode)) {
            /* this file is a device. we don't write back to it. 
             * we "succeed" on the assumption this is some sort 
             * of random device. Otherwise attempting to write to