precised size types to ssize_t instead of int

This commit is contained in:
yrutschle 2021-02-08 22:50:53 +01:00
parent 52a9356c35
commit 9ff9723278
2 changed files with 20 additions and 20 deletions

38
probe.c
View File

@ -33,15 +33,15 @@
static int is_ssh_protocol(const char *p, int len, struct sslhcfg_protocols_item*);
static int is_openvpn_protocol(const char *p, int len, struct sslhcfg_protocols_item*);
static int is_tinc_protocol(const char *p, int len, struct sslhcfg_protocols_item*);
static int is_xmpp_protocol(const char *p, int len, struct sslhcfg_protocols_item*);
static int is_http_protocol(const char *p, int len, struct sslhcfg_protocols_item*);
static int is_tls_protocol(const char *p, int len, struct sslhcfg_protocols_item*);
static int is_adb_protocol(const char *p, int len, struct sslhcfg_protocols_item*);
static int is_socks5_protocol(const char *p, int len, struct sslhcfg_protocols_item*);
static int is_true(const char *p, int len, struct sslhcfg_protocols_item* proto) { return 1; }
static int is_ssh_protocol(const char *p, ssize_t len, struct sslhcfg_protocols_item*);
static int is_openvpn_protocol(const char *p, ssize_t len, struct sslhcfg_protocols_item*);
static int is_tinc_protocol(const char *p, ssize_t len, struct sslhcfg_protocols_item*);
static int is_xmpp_protocol(const char *p, ssize_t len, struct sslhcfg_protocols_item*);
static int is_http_protocol(const char *p, ssize_t len, struct sslhcfg_protocols_item*);
static int is_tls_protocol(const char *p, ssize_t len, struct sslhcfg_protocols_item*);
static int is_adb_protocol(const char *p, ssize_t len, struct sslhcfg_protocols_item*);
static int is_socks5_protocol(const char *p, ssize_t len, struct sslhcfg_protocols_item*);
static int is_true(const char *p, ssize_t len, struct sslhcfg_protocols_item* proto) { return 1; }
/* Table of protocols that have a built-in probe
*/
@ -114,7 +114,7 @@ void hexdump(const char *mem, unsigned int len)
}
/* Is the buffer the beginning of an SSH connection? */
static int is_ssh_protocol(const char *p, int len, struct sslhcfg_protocols_item* proto)
static int is_ssh_protocol(const char *p, ssize_t len, struct sslhcfg_protocols_item* proto)
{
if (len < 4)
return PROBE_AGAIN;
@ -132,7 +132,7 @@ static int is_ssh_protocol(const char *p, int len, struct sslhcfg_protocols_item
* http://www.fengnet.com/book/vpns%20illustrated%20tunnels%20%20vpnsand%20ipsec/ch08lev1sec5.html
* and OpenVPN ssl.c, ssl.h and options.c
*/
static int is_openvpn_protocol (const char*p,int len, struct sslhcfg_protocols_item* proto)
static int is_openvpn_protocol (const char*p,ssize_t len, struct sslhcfg_protocols_item* proto)
{
int packet_len;
@ -147,7 +147,7 @@ static int is_openvpn_protocol (const char*p,int len, struct sslhcfg_protocols_i
* Protocol is documented here: http://www.tinc-vpn.org/documentation/tinc.pdf
* First connection starts with "0 " in 1.0.15)
* */
static int is_tinc_protocol( const char *p, int len, struct sslhcfg_protocols_item* proto)
static int is_tinc_protocol( const char *p, ssize_t len, struct sslhcfg_protocols_item* proto)
{
if (len < 2)
return PROBE_AGAIN;
@ -159,7 +159,7 @@ static int is_tinc_protocol( const char *p, int len, struct sslhcfg_protocols_it
* (Protocol is documented (http://tools.ietf.org/html/rfc6120) but for lazy
* clients, just checking first frame containing "jabber" in xml entity)
* */
static int is_xmpp_protocol( const char *p, int len, struct sslhcfg_protocols_item* proto)
static int is_xmpp_protocol( const char *p, ssize_t len, struct sslhcfg_protocols_item* proto)
{
if (memmem(p, len, "jabber", 6))
return PROBE_MATCH;
@ -182,7 +182,7 @@ static int probe_http_method(const char *p, int len, const char *opt)
}
/* Is the buffer the beginning of an HTTP connection? */
static int is_http_protocol(const char *p, int len, struct sslhcfg_protocols_item* proto)
static int is_http_protocol(const char *p, ssize_t len, struct sslhcfg_protocols_item* proto)
{
int res;
/* If it's got HTTP in the request (HTTP/1.1) then it's HTTP */
@ -208,7 +208,7 @@ static int is_http_protocol(const char *p, int len, struct sslhcfg_protocols_ite
}
/* Says if it's TLS, optionally with SNI and ALPN lists in proto->data */
static int is_tls_protocol(const char *p, int len, struct sslhcfg_protocols_item* proto)
static int is_tls_protocol(const char *p, ssize_t len, struct sslhcfg_protocols_item* proto)
{
switch (parse_tls_header(proto->data, p, len)) {
case TLS_MATCH: return PROBE_MATCH;
@ -228,7 +228,7 @@ static int probe_adb_cnxn_message(const char *p)
return !memcmp(&p[0], "CNXN", 4) && !memcmp(&p[24], "host:", 5);
}
static int is_adb_protocol(const char *p, int len, struct sslhcfg_protocols_item* proto)
static int is_adb_protocol(const char *p, ssize_t len, struct sslhcfg_protocols_item* proto)
{
/* amessage.data_length is not being checked, under the assumption that
* a packet >= 30 bytes will have "something" in the payload field.
@ -267,7 +267,7 @@ static int is_adb_protocol(const char *p, int len, struct sslhcfg_protocols_item
return probe_adb_cnxn_message(&p[sizeof(empty_message)]);
}
static int is_socks5_protocol(const char *p_in, int len, struct sslhcfg_protocols_item* proto)
static int is_socks5_protocol(const char *p_in, ssize_t len, struct sslhcfg_protocols_item* proto)
{
unsigned char* p = (unsigned char*)p_in;
int i;
@ -300,7 +300,7 @@ static int is_socks5_protocol(const char *p_in, int len, struct sslhcfg_protocol
return PROBE_MATCH;
}
static int regex_probe(const char *p, int len, struct sslhcfg_protocols_item* proto)
static int regex_probe(const char *p, ssize_t len, struct sslhcfg_protocols_item* proto)
{
#ifdef ENABLE_REGEX
regex_t **probe = proto->data;
@ -379,7 +379,7 @@ int probe_buffer(char* buf, int len, struct sslhcfg_protocols_item** proto)
int probe_client_protocol(struct connection *cnx)
{
char buffer[BUFSIZ];
int n;
ssize_t n;
n = read(cnx->q[0].fd, buffer, sizeof(buffer));
/* It's possible that read() returns an error, e.g. if the client

View File

@ -13,7 +13,7 @@ typedef enum {
} probe_result;
struct sslhcfg_protocols_item;
typedef int T_PROBE(const char*, int, struct sslhcfg_protocols_item*);
typedef int T_PROBE(const char*, ssize_t, struct sslhcfg_protocols_item*);
struct protocol_probe_desc {
const char* name;