[Git][NTPsec/ntpsec][master] 2 commits: Tweaks to attic/tester.c for testing partial reads
Hal Murray (@hal.murray)
gitlab at mg.gitlab.com
Wed Sep 3 12:01:26 UTC 2025
Hal Murray pushed to branch master at NTPsec / ntpsec
Commits:
92967152 by Hal Murray at 2025-09-03T05:00:57-07:00
Tweaks to attic/tester.c for testing partial reads
- - - - -
c7a86a0a by Hal Murray at 2025-09-03T05:00:57-07:00
Fix Coverity CID 584869
- - - - -
2 changed files:
- attic/tls-tester.c
- ntpd/refclock_hpgps.c
Changes:
=====================================
attic/tls-tester.c
=====================================
@@ -43,7 +43,8 @@ struct BufCtl_t {
typedef struct BufCtl_t BufCtl;
void append_record16(BufCtl* buf, uint16_t type, uint16_t data);
-void append_record(BufCtl* buf, uint16_t type);
+void append_header(BufCtl* buf, uint16_t type, uint16_t length);
+void append_uint16(BufCtl* buf, uint16_t data);
static void do_args (int argc, char *argv[]) {
@@ -147,12 +148,17 @@ static void print_buf(uint8_t *buff, int bytes) {
bytes -=4;
buff += length;
bytes -= length;
- if (2==length) {
- uint16_t data = ntohs(*buff16++);
- printf(" type=0x%04x, lng=%d, data=0x%0x\n", type, length, data);
+ printf(" type=0x%04x, lng=%d", type, length);
+ if (20<length) {
+ printf("\n");
continue;
}
- printf(" type=0x%04x, lng=%d\n", type, length);
+ while (0<length) {
+ uint16_t data = ntohs(*buff16++);
+ length-=2;
+ printf(", data=0x%0x(%d)", data, data);
+ }
+ printf("\n");
}
}
@@ -254,7 +260,7 @@ int main (int argc, char *argv[]) {
buf.left = sizeof(buff);
append_record16(&buf, 0x8001, 0); // next protocol
append_record16(&buf, 4, 15); // algorithm_negotiation
- append_record(&buf, 0x8000); // end_of_message
+ append_header(&buf, 0x8000, 0); // end_of_message
bytes = sizeof(buff)-buf.left;
printf("Sending %d bytes\n", bytes);
print_buf(buff, bytes);
@@ -280,19 +286,22 @@ int main (int argc, char *argv[]) {
/* no error checking, length excludes header */
void append_record16(BufCtl* buf, uint16_t type, uint16_t data) {
- uint16_t * ptr = (uint16_t *)buf->next;
- *ptr++ = htons(type);
- *ptr++ = htons(2);
- *ptr++ = htons(data);
- buf->next += 6;
- buf->left -= 6;
+ append_header(buf, type, 2);
+ append_uint16(buf, data);
}
-void append_record(BufCtl* buf, uint16_t type) {
- uint16_t * ptr = (uint16_t *)buf->next;
+void append_header(BufCtl* buf, uint16_t type, uint16_t length) {
+ uint16_t *ptr = (uint16_t *)buf->next;
*ptr++ = htons(type);
- *ptr++ = htons(0);
+ *ptr++ = htons(length);
buf->next += 4;
buf->left -= 4;
}
+void append_uint16(BufCtl* buf, uint16_t data) {
+ uint16_t *ptr = (uint16_t *)buf->next;
+ *ptr++ = htons(data);
+ buf->next += 2;
+ buf->left -= 2;
+}
+
=====================================
ntpd/refclock_hpgps.c
=====================================
@@ -559,6 +559,7 @@ bool hpgps_receive_T2(struct peer *const peer)
*/
tm.tm_year -= 1900;
tm.tm_mon -= 1;
+ tm.tm_isdst = 0; /* Coverity CID 584869, UNINIT */
date.tv_nsec = 0;
date.tv_sec = timegm(&tm); /* No error checking */
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/compare/29a78cc01fc71c3cf6cdd8862ce9d28d9769839b...c7a86a0a73121292cca24e70558049e9856e890b
--
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/compare/29a78cc01fc71c3cf6cdd8862ce9d28d9769839b...c7a86a0a73121292cca24e70558049e9856e890b
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20250903/c6f932ee/attachment-0001.htm>
More information about the vc
mailing list