From: Juergen Perlinger Date: Sat, 2 Aug 2014 11:15:10 +0000 (+0200) Subject: make consistent layout for 'struct pkt' X-Git-Tag: NTP_4_2_7P455~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9e73a2694aa0d8e38aa967fa669d734bea224101;p=thirdparty%2Fntp.git make consistent layout for 'struct pkt' bk: 53dcc83eDvaWAxmqmyZIG0Ucn-ifew --- diff --git a/include/ntp.h b/include/ntp.h index d485de03b..60adc4f34 100644 --- a/include/ntp.h +++ b/include/ntp.h @@ -557,13 +557,19 @@ struct pkt { * response, so the maximum total extension field length is 864 * octets. But, to handle humungus certificates, the bank must * be broke. + * + * The different definitions of the 'exten' field are here for + * the benefit of applications that want to send a packet from + * an auto variable in the stack - not using the AUTOKEY version + * saves 2KB of stack space. The receive buffer should ALWAYS be + * big enough to hold a full extended packet if the extension + * fields have to be parsed or skipped. */ #ifdef AUTOKEY - u_int32 exten[NTP_MAXEXTEN / 4]; /* max extension field */ + u_int32 exten[(NTP_MAXEXTEN + MAX_MAC_LEN) / sizeof(u_int32)]; #else /* !AUTOKEY follows */ - u_int32 exten[1]; /* misused */ + u_int32 exten[(MAX_MAC_LEN) / sizeof(u_int32)]; #endif /* !AUTOKEY */ - u_char mac[MAX_MAC_LEN]; /* mac */ }; /* diff --git a/libntp/work_thread.c b/libntp/work_thread.c index cf41de9c4..38d87470f 100644 --- a/libntp/work_thread.c +++ b/libntp/work_thread.c @@ -40,7 +40,7 @@ # define thread_exit(c) _endthreadex(c) # define tickle_sem SetEvent #else -# define thread_exit(c) pthread_exit((void *)(c)) +# define thread_exit(c) pthread_exit((void*)(size_t)(c)) # define tickle_sem sem_post #endif diff --git a/sntp/main.c b/sntp/main.c index ee59714b4..d60710868 100644 --- a/sntp/main.c +++ b/sntp/main.c @@ -85,7 +85,7 @@ sent_pkt * fam_listheads[2]; static union { struct pkt pkt; - char buf[1500]; + char buf[LEN_PKT_NOMAC + NTP_MAXEXTEN + MAX_MAC_LEN]; } rbuf; #define r_pkt rbuf.pkt @@ -295,9 +295,7 @@ open_sockets( ) { sockaddr_u name; - int one_fam_works; - one_fam_works = FALSE; if (-1 == sock4) { sock4 = socket(PF_INET, SOCK_DGRAM, 0); if (-1 == sock4) { @@ -328,7 +326,6 @@ open_sockets( msyslog(LOG_ERR, "open_sockets: event_new(base, sock4) failed!"); } else { - one_fam_works = TRUE; event_add(ev_sock4, &wakeup_tv); } } @@ -363,7 +360,6 @@ open_sockets( msyslog(LOG_ERR, "open_sockets: event_new(base, sock6) failed!"); } else { - one_fam_works = TRUE; event_add(ev_sock6, &wakeup_tv); } }