Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/dist/ntp use return value of openssl's RAND_file_name(), thi...



details:   https://anonhg.NetBSD.org/src/rev/e5e7f766623e
branches:  trunk
changeset: 555928:e5e7f766623e
user:      drochner <drochner%NetBSD.org@localhost>
date:      Thu Dec 04 17:06:12 2003 +0000

description:
use return value of openssl's RAND_file_name(), this makes the
fallback to /dev/urandom work as intended by openssl
(ntp bug #234)

diffstat:

 dist/ntp/ntpd/ntp_crypto.c |  10 ++++++----
 dist/ntp/util/ntp-keygen.c |  12 +++++++-----
 2 files changed, 13 insertions(+), 9 deletions(-)

diffs (73 lines):

diff -r f09d17685477 -r e5e7f766623e dist/ntp/ntpd/ntp_crypto.c
--- a/dist/ntp/ntpd/ntp_crypto.c        Thu Dec 04 17:01:32 2003 +0000
+++ b/dist/ntp/ntpd/ntp_crypto.c        Thu Dec 04 17:06:12 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ntp_crypto.c,v 1.3 2003/12/04 16:23:37 drochner Exp $  */
+/*     $NetBSD: ntp_crypto.c,v 1.4 2003/12/04 17:06:12 drochner Exp $  */
 
 /*
  * ntp_crypto.c - NTP version 4 public key routines
@@ -3723,6 +3723,7 @@
        tstamp_t sstamp;        /* sign filestamp */
        u_int   len, bytes;
        u_char  *ptr;
+       const char *fnptr;
 
        /*
         * Initialize structures.
@@ -3748,9 +3749,10 @@
         */
        ERR_load_crypto_strings();
        if (rand_file == NULL) {
-               if ((RAND_file_name(filename, MAXFILENAME)) != NULL) {
-                       rand_file = emalloc(strlen(filename) + 1);
-                       strcpy(rand_file, filename);
+               fnptr = RAND_file_name(filename, MAXFILENAME);
+               if (fnptr != NULL) {
+                       rand_file = emalloc(strlen(fnptr) + 1);
+                       strcpy(rand_file, fnptr);
                }
        } else if (*rand_file != '/') {
                snprintf(filename, MAXFILENAME, "%s/%s", keysdir,
diff -r f09d17685477 -r e5e7f766623e dist/ntp/util/ntp-keygen.c
--- a/dist/ntp/util/ntp-keygen.c        Thu Dec 04 17:01:32 2003 +0000
+++ b/dist/ntp/util/ntp-keygen.c        Thu Dec 04 17:06:12 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ntp-keygen.c,v 1.2 2003/12/04 16:23:38 drochner Exp $  */
+/*     $NetBSD: ntp-keygen.c,v 1.3 2003/12/04 17:06:12 drochner Exp $  */
 
 /*
  * Program to generate cryptographic keys for NTP clients and servers
@@ -241,6 +241,7 @@
        int     nid;            /* X509 digest/signature scheme */
        FILE    *fstr = NULL;   /* file handle */
        int     iffsw = 0;      /* IFF key switch */
+       const char *fnptr;
 #endif /* OPENSSL */
        u_int   temp;
 
@@ -434,19 +435,20 @@
         */
        ERR_load_crypto_strings();
        OpenSSL_add_all_algorithms();
-       if (RAND_file_name(pathbuf, MAXFILENAME) == NULL) {
+       fnptr = RAND_file_name(pathbuf, MAXFILENAME);
+       if (fnptr == NULL) {
                fprintf(stderr, "RAND_file_name %s\n",
                    ERR_error_string(ERR_get_error(), NULL));
                return (-1);
        }
-       temp = RAND_load_file(pathbuf, -1);
+       temp = RAND_load_file(fnptr, -1);
        if (temp == 0) {
                fprintf(stderr,
-                   "RAND_load_file %s not found or empty\n", pathbuf);
+                   "RAND_load_file %s not found or empty\n", fnptr);
                return (-1);
        }
        fprintf(stderr,
-           "Random seed file %s %u bytes\n", pathbuf, temp);
+           "Random seed file %s %u bytes\n", fnptr, temp);
        RAND_add(&epoch, sizeof(epoch), 4.0);
 
        /*



Home | Main Index | Thread Index | Old Index