Use SCN* constants when reading into sized integer types

This commit is contained in:
Tim Wojtulewicz 2025-05-21 10:50:38 -07:00
parent ff4d1a4121
commit 1992a55798
3 changed files with 9 additions and 8 deletions

View file

@ -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;

View file

@ -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 {

View file

@ -11,7 +11,7 @@
#include <sys/stat.h>
#include <algorithm>
#include <cmath>
#include <cinttypes>
#include <cmath>
#include <cstdio>
#include <cstring>
@ -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,