From 1992a55798d95a24a1c7e4506f8d15aabe045b81 Mon Sep 17 00:00:00 2001 From: Tim Wojtulewicz Date: Wed, 21 May 2025 10:50:38 -0700 Subject: [PATCH] Use SCN* constants when reading into sized integer types --- src/DNS_Mapping.cc | 2 +- src/analyzer/protocol/bittorrent/BitTorrentTracker.cc | 4 ++-- src/zeek.bif | 11 ++++++----- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/DNS_Mapping.cc b/src/DNS_Mapping.cc index a1299974ec..4d7c6ff01d 100644 --- a/src/DNS_Mapping.cc +++ b/src/DNS_Mapping.cc @@ -48,7 +48,7 @@ DNS_Mapping::DNS_Mapping(FILE* f) { int failed_local; int num_addrs; - if ( sscanf(buf, "%lf %d %512s %d %512s %d %d %" PRIu32, &creation_time, &is_req_host, req_buf, &failed_local, + if ( sscanf(buf, "%lf %d %512s %d %512s %d %d %" SCNu32, &creation_time, &is_req_host, req_buf, &failed_local, name_buf, &req_type, &num_addrs, &req_ttl) != 8 ) { no_mapping = true; return; diff --git a/src/analyzer/protocol/bittorrent/BitTorrentTracker.cc b/src/analyzer/protocol/bittorrent/BitTorrentTracker.cc index 52fd6d23bf..178687623c 100644 --- a/src/analyzer/protocol/bittorrent/BitTorrentTracker.cc +++ b/src/analyzer/protocol/bittorrent/BitTorrentTracker.cc @@ -11,8 +11,8 @@ #include "zeek/analyzer/protocol/bittorrent/events.bif.h" #include "zeek/analyzer/protocol/tcp/TCP_Reassembler.h" -#define FMT_INT "%" PRId64 -#define FMT_UINT "%" PRIu64 +#define FMT_INT "%" SCNd64 +#define FMT_UINT "%" SCNu64 namespace zeek::analyzer::bittorrent { diff --git a/src/zeek.bif b/src/zeek.bif index 93f9569850..05e030654a 100644 --- a/src/zeek.bif +++ b/src/zeek.bif @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include #include @@ -3299,10 +3299,11 @@ function ptr_name_to_addr%(s: string%): addr uint32_t b[32]; char ss[9]; // this will contain "ip6.arpa" if ( sscanf(s->CheckString(), - "%1x.%1x.%1x.%1x.%1x.%1x.%1x.%1x." - "%1x.%1x.%1x.%1x.%1x.%1x.%1x.%1x." - "%1x.%1x.%1x.%1x.%1x.%1x.%1x.%1x." - "%1x.%1x.%1x.%1x.%1x.%1x.%1x.%1x.%8s", + "%1" SCNx32 "%1" SCNx32 "%1" SCNx32 "%1" SCNx32 "%1" SCNx32 "%1" SCNx32 "%1" SCNx32 "%1" SCNx32 + "%1" SCNx32 "%1" SCNx32 "%1" SCNx32 "%1" SCNx32 "%1" SCNx32 "%1" SCNx32 "%1" SCNx32 "%1" SCNx32 + "%1" SCNx32 "%1" SCNx32 "%1" SCNx32 "%1" SCNx32 "%1" SCNx32 "%1" SCNx32 "%1" SCNx32 "%1" SCNx32 + "%1" SCNx32 "%1" SCNx32 "%1" SCNx32 "%1" SCNx32 "%1" SCNx32 "%1" SCNx32 "%1" SCNx32 "%1" SCNx32 + "%8s", b+31, b+30, b+29, b+28, b+27, b+26, b+25, b+24, b+23, b+22, b+21, b+20, b+19, b+18, b+17, b+16, b+15, b+14, b+13, b+12, b+11, b+10, b+9, b+8,