mirror of
https://github.com/zeek/zeek.git
synced 2025-10-01 22:28:20 +00:00
src/3rdparty: Use snprintf in patricia.cc to silence macOS compiler warnings
This commit is contained in:
parent
2d9eb155d5
commit
a2abb40af6
1 changed files with 6 additions and 5 deletions
11
src/3rdparty/patricia.c
vendored
11
src/3rdparty/patricia.c
vendored
|
@ -51,7 +51,7 @@ UNUSED static char copyright[] = "This product includes software developed by "
|
||||||
#include <math.h> /* sin */
|
#include <math.h> /* sin */
|
||||||
#include <netinet/in.h> /* BSD, Linux: for inet_addr */
|
#include <netinet/in.h> /* BSD, Linux: for inet_addr */
|
||||||
#include <stddef.h> /* NULL */
|
#include <stddef.h> /* NULL */
|
||||||
#include <stdio.h> /* sprintf, fprintf, stderr */
|
#include <stdio.h> /* snprintf, fprintf, stderr */
|
||||||
#include <stdlib.h> /* free, atol, calloc */
|
#include <stdlib.h> /* free, atol, calloc */
|
||||||
#include <string.h> /* memcpy, strchr, strlen */
|
#include <string.h> /* memcpy, strchr, strlen */
|
||||||
#include <sys/socket.h> /* BSD, Linux: for inet_addr */
|
#include <sys/socket.h> /* BSD, Linux: for inet_addr */
|
||||||
|
@ -131,6 +131,7 @@ int my_inet_pton(int af, const char *src, void *dst)
|
||||||
}
|
}
|
||||||
|
|
||||||
#define PATRICIA_MAX_THREADS 16
|
#define PATRICIA_MAX_THREADS 16
|
||||||
|
#define PATRICIA_PREFIX_BUF_LEN 53
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* convert prefix information to ascii string with length
|
* convert prefix information to ascii string with length
|
||||||
|
@ -144,7 +145,7 @@ char *prefix_toa2x(prefix_t *prefix, char *buff, int with_len)
|
||||||
if (buff == NULL) {
|
if (buff == NULL) {
|
||||||
|
|
||||||
struct buffer {
|
struct buffer {
|
||||||
char buffs[PATRICIA_MAX_THREADS][48 + 5];
|
char buffs[PATRICIA_MAX_THREADS][PATRICIA_PREFIX_BUF_LEN];
|
||||||
u_int i;
|
u_int i;
|
||||||
} * buffp;
|
} * buffp;
|
||||||
|
|
||||||
|
@ -168,9 +169,9 @@ char *prefix_toa2x(prefix_t *prefix, char *buff, int with_len)
|
||||||
assert(prefix->bitlen <= sizeof(struct in_addr) * 8);
|
assert(prefix->bitlen <= sizeof(struct in_addr) * 8);
|
||||||
a = prefix_touchar(prefix);
|
a = prefix_touchar(prefix);
|
||||||
if (with_len) {
|
if (with_len) {
|
||||||
sprintf(buff, "%d.%d.%d.%d/%d", a[0], a[1], a[2], a[3], prefix->bitlen);
|
snprintf(buff, PATRICIA_PREFIX_BUF_LEN, "%d.%d.%d.%d/%d", a[0], a[1], a[2], a[3], prefix->bitlen);
|
||||||
} else {
|
} else {
|
||||||
sprintf(buff, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
|
snprintf(buff, PATRICIA_PREFIX_BUF_LEN, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
|
||||||
}
|
}
|
||||||
return (buff);
|
return (buff);
|
||||||
}
|
}
|
||||||
|
@ -181,7 +182,7 @@ char *prefix_toa2x(prefix_t *prefix, char *buff, int with_len)
|
||||||
48 /* a guess value */);
|
48 /* a guess value */);
|
||||||
if (r && with_len) {
|
if (r && with_len) {
|
||||||
assert(prefix->bitlen <= sizeof(struct in6_addr) * 8);
|
assert(prefix->bitlen <= sizeof(struct in6_addr) * 8);
|
||||||
sprintf(buff + strlen(buff), "/%d", prefix->bitlen);
|
snprintf(buff + strlen(buff), PATRICIA_PREFIX_BUF_LEN-strlen(buff), "/%d", prefix->bitlen);
|
||||||
}
|
}
|
||||||
return (buff);
|
return (buff);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue