]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 1343] ntpd/ntp_io.c close_fd() does not compile on Solaris 7.
authorDave Hart <hart@ntp.org>
Mon, 19 Oct 2009 17:23:04 +0000 (17:23 +0000)
committerDave Hart <hart@ntp.org>
Mon, 19 Oct 2009 17:23:04 +0000 (17:23 +0000)
Also includes similar fix to sntp/crypto.c identified on same machine.

bk: 4adca078XA_VEptIuwuTbB4noDVp9g

ChangeLog
ntpd/ntp_io.c
sntp/crypto.c

index 9a62b14a670c77b23d172abac1979d97483273f5..d7940447bb0c948ab0159f3bc2fe7532e75761a8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,4 @@
+* [Bug 1343] ntpd/ntp_io.c close_fd() does not compile on Solaris 7.
 (4.2.5p235-RC) 2009/10/18 Released by Harlan Stenn <stenn@ntp.org>
 * [Bug 1343] lib/isc build breaks on systems without IPv6 headers.
 (4.2.5p234-RC) 2009/10/16 Released by Harlan Stenn <stenn@ntp.org>
index 1f439f22a2e836f61328f051516326de9a121234..8f0c220a43a9a15856882e600b7a4315523e440e 100644 (file)
@@ -416,8 +416,6 @@ move_fd(
        SOCKET fd
        )
 {
-       NTP_REQUIRE((int)fd >= 0);
-
 #if !defined(SYS_WINNT) && defined(F_DUPFD)
 #ifndef FD_CHUNK
 #define FD_CHUNK       10
@@ -449,6 +447,8 @@ move_fd(
        static SOCKET socket_boundary = -1;
        SOCKET newfd;
 
+       NTP_REQUIRE((int)fd >= 0);
+
        /*
         * check whether boundary has be set up
         * already
@@ -488,6 +488,8 @@ move_fd(
                        socket_boundary);
 #endif
        } while (socket_boundary > 0);
+#else
+       NTP_REQUIRE((int)fd >= 0);
 #endif /* !defined(SYS_WINNT) && defined(F_DUPFD) */
        return fd;
 }
index 9f209684447256f0a39a02e9684c9012a54d1daf..d3dcf33acf67b8a972591f691aeb08a8772c985c 100644 (file)
@@ -26,36 +26,37 @@ int key_cnt = 0;
  * authentic) or else 0 (not authentic).
  */
 int
-auth_md5 (
-               char *pkt_data,
-               int mac_size,
-               struct key *cmp_key
-        )
+auth_md5(
+       char *pkt_data,
+       int mac_size,
+       struct key *cmp_key
+       )
 {
        register int a;
        char digest[16];
        MD5_CTX ctx;
+       char *digest_data;
 
-       if(cmp_key->type != 'M')
+       if (cmp_key->type != 'M')
                return -1;
        
        MD5Init(&ctx);
 
-       char *digest_data = (char *) emalloc(sizeof(char) * (LEN_PKT_NOMAC + cmp_key->key_len));
+       digest_data = emalloc(sizeof(char) * (LEN_PKT_NOMAC + cmp_key->key_len));
 
-       for(a=0; a<LEN_PKT_NOMAC; a++)
+       for (a = 0; a < LEN_PKT_NOMAC; a++)
                digest_data[a] = pkt_data[a];
 
-       for(a=0; a<cmp_key->key_len; a++)
+       for (a = 0; a < cmp_key->key_len; a++)
                digest_data[LEN_PKT_NOMAC + a] = cmp_key->key_seq[a];
 
-       MD5Update(&ctx, (unsigned char *)digest_data, LEN_PKT_NOMAC + cmp_key->key_len);
-       MD5Final((unsigned char *)digest, &ctx);
+       MD5Update(&ctx, (u_char *)digest_data, LEN_PKT_NOMAC + cmp_key->key_len);
+       MD5Final((u_char *)digest, &ctx);
 
        free(digest_data);
 
-       for(a=0; a<16; a++)
-               if(digest[a] != pkt_data[LEN_PKT_MAC + a])
+       for (a = 0; a < 16; a++)
+               if (digest[a] != pkt_data[LEN_PKT_MAC + a])
                        return 0;
 
        return 1;
@@ -66,20 +67,19 @@ auth_md5 (
  * number of keys it read
  */
 int
-auth_init (
-               const char *keyfile,
-               struct key **keys
-               )
+auth_init(
+       const char *keyfile,
+       struct key **keys
+       )
 {
        FILE *keyf = fopen(keyfile, "r"); 
        struct key *prev = NULL;
-
        register int a, line_limit;
        int scan_cnt, line_cnt = 0;
        char kbuf[96];
 
-       if(keyf == NULL) {
-               if(ENABLED_OPT(NORMALVERBOSE))
+       if (keyf == NULL) {
+               if (ENABLED_OPT(NORMALVERBOSE))
                        printf("sntp auth_init: Couldn't open key file %s for reading!\n", keyfile);
 
                return -1;
@@ -87,29 +87,28 @@ auth_init (
 
        line_cnt = 0;
        
-       if(feof(keyf)) {
-               if(ENABLED_OPT(NORMALVERBOSE))
+       if (feof(keyf)) {
+               if (ENABLED_OPT(NORMALVERBOSE))
                        printf("sntp auth_init: Key file %s is empty!\n", keyfile);
                fclose(keyf);
 
                return -1;
        }
 
-
-       while(!feof(keyf)) {
-               struct key *act = (struct key *) emalloc(sizeof(struct key));
+       while (!feof(keyf)) {
+               struct key *act = emalloc(sizeof(struct key));
                line_limit = 0;
 
                fgets(kbuf, sizeof(kbuf), keyf);
                
-               for(a=0; a<strlen(kbuf) && a < sizeof(kbuf); a++) {
-                       if(kbuf[a] == '#') {
+               for (a = 0; a < strlen(kbuf) && a < sizeof(kbuf); a++) {
+                       if (kbuf[a] == '#') {
                                line_limit = a;
                                break;
                        }
                }
 
-               if(line_limit != 0)
+               if (line_limit != 0)
                        kbuf[line_limit] = '\0';
 
 #ifdef DEBUG
@@ -117,7 +116,7 @@ auth_init (
 #endif
                
 
-               if((scan_cnt = sscanf(kbuf, "%i %c %16s", &act->key_id, &act->type, act->key_seq)) == 3) {
+               if ((scan_cnt = sscanf(kbuf, "%i %c %16s", &act->key_id, &act->type, act->key_seq)) == 3) {
                        act->key_len = strlen(act->key_seq);
                        act->next = NULL;
 
@@ -132,8 +131,7 @@ auth_init (
 #ifdef DEBUG
                        printf("sntp auth_init: key_id %i type %c with key %s\n", act->key_id, act->type, act->key_seq);
 #endif
-               }
-               else {
+               } else {
 #ifdef DEBUG
                        printf("sntp auth_init: scanf read %i items, doesn't look good, skipping line %i.\n", scan_cnt, line_cnt);
 #endif
@@ -150,11 +148,14 @@ auth_init (
        STDLINE
        printf("sntp auth_init: Read %i keys from file %s:\n", line_cnt, keyfile);
 
-       struct key *kptr = *keys;
-       for(a=0; a<key_cnt; a++) {
-               printf("key_id %i type %c with key %s (key length: %i)\n", kptr->key_id, 
-                               kptr->type, kptr->key_seq, kptr->key_len);
-               kptr = kptr->next;
+       {
+               struct key *kptr = *keys;
+
+               for (a = 0; a < key_cnt; a++) {
+                       printf("key_id %i type %c with key %s (key length: %i)\n",
+                              kptr->key_id, kptr->type, kptr->key_seq, kptr->key_len);
+                       kptr = kptr->next;
+               }
        }
        STDLINE
 #endif
@@ -169,19 +170,19 @@ auth_init (
  * address of the key. If no matching key is found the pointer is not touched.
  */
 void
-get_key (
-               int key_id,
-               struct key **d_key
-               )
+get_key(
+       int key_id,
+       struct key **d_key
+       )
 {
        register int a;
        struct key *itr_key = key_ptr;
 
-       if(key_cnt == 0)
+       if (key_cnt == 0)
                return;
        
-       for(a=0; a<key_cnt && itr_key != NULL; a++) {
-               if(itr_key->key_id == key_id) {
+       for (a = 0; a < key_cnt && itr_key != NULL; a++) {
+               if (itr_key->key_id == key_id) {
                        *d_key = itr_key;
                        return;
                }