Drop remaining usage of u_char in favour of standard C99 uint8_t (#8611)

Plus minor drive-by fixes
This commit is contained in:
George Peter Banyard 2022-05-23 21:57:31 +01:00 committed by GitHub
parent 59b4fdbb2b
commit 9f06bb3bb6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 21 deletions

View File

@ -913,7 +913,7 @@ static bool netsnmp_session_init(php_snmp_session **session_p, int version, zend
session->securityNameLen = ZSTR_LEN(community);
} else {
session->authenticator = NULL;
session->community = (u_char *)estrdup(ZSTR_VAL(community));
session->community = (uint8_t *)estrdup(ZSTR_VAL(community));
session->community_len = ZSTR_LEN(community);
}
@ -1035,7 +1035,7 @@ static bool netsnmp_session_gen_auth_key(struct snmp_session *s, zend_string *pa
int snmp_errno;
s->securityAuthKeyLen = USM_AUTH_KU_LEN;
if ((snmp_errno = generate_Ku(s->securityAuthProto, s->securityAuthProtoLen,
(u_char *) ZSTR_VAL(pass), ZSTR_LEN(pass),
(uint8_t *) ZSTR_VAL(pass), ZSTR_LEN(pass),
s->securityAuthKey, &(s->securityAuthKeyLen)))) {
php_error_docref(NULL, E_WARNING, "Error generating a key for authentication pass phrase '%s': %s", ZSTR_VAL(pass), snmp_api_errstring(snmp_errno));
return false;
@ -1051,7 +1051,7 @@ static bool netsnmp_session_gen_sec_key(struct snmp_session *s, zend_string *pas
s->securityPrivKeyLen = USM_PRIV_KU_LEN;
if ((snmp_errno = generate_Ku(s->securityAuthProto, s->securityAuthProtoLen,
(u_char *)ZSTR_VAL(pass), ZSTR_LEN(pass),
(uint8_t *)ZSTR_VAL(pass), ZSTR_LEN(pass),
s->securityPrivKey, &(s->securityPrivKeyLen)))) {
php_error_docref(NULL, E_WARNING, "Error generating a key for privacy pass phrase '%s': %s", ZSTR_VAL(pass), snmp_api_errstring(snmp_errno));
return false;
@ -1064,7 +1064,7 @@ static bool netsnmp_session_gen_sec_key(struct snmp_session *s, zend_string *pas
static bool netsnmp_session_set_contextEngineID(struct snmp_session *s, zend_string * contextEngineID)
{
size_t ebuf_len = 32, eout_len = 0;
u_char *ebuf = (u_char *) emalloc(ebuf_len);
uint8_t *ebuf = (uint8_t *) emalloc(ebuf_len);
if (!snmp_hex_to_binary(&ebuf, &ebuf_len, &eout_len, 1, ZSTR_VAL(contextEngineID))) {
// TODO Promote to Error?

View File

@ -356,7 +356,7 @@ static zend_string *php_gethostbyname(char *name)
typedef union {
HEADER qb1;
u_char qb2[65536];
uint8_t qb2[65536];
} querybuf;
/* just a hack to free resources allocated by glibc in __res_nsend()
@ -463,13 +463,13 @@ PHP_FUNCTION(dns_check_record)
} while (0)
/* {{{ php_parserr */
static u_char *php_parserr(u_char *cp, u_char *end, querybuf *answer, int type_to_fetch, int store, int raw, zval *subarray)
static uint8_t *php_parserr(uint8_t *cp, uint8_t *end, querybuf *answer, int type_to_fetch, int store, bool raw, zval *subarray)
{
u_short type, class, dlen;
u_long ttl;
long n, i;
u_short s;
u_char *tp, *p;
uint8_t *tp, *p;
char name[MAXHOSTNAMELEN] = {0};
int have_v6_break = 0, in_v6_break = 0;
@ -648,12 +648,12 @@ static u_char *php_parserr(u_char *cp, u_char *end, querybuf *answer, int type_t
add_assoc_long(subarray, "minimum-ttl", n);
break;
case DNS_T_AAAA:
tp = (u_char*)name;
tp = (uint8_t*)name;
CHECKCP(8*2);
for(i=0; i < 8; i++) {
GETSHORT(s, cp);
if (s != 0) {
if (tp > (u_char *)name) {
if (tp > (uint8_t *)name) {
in_v6_break = 0;
tp[0] = ':';
tp++;
@ -688,7 +688,7 @@ static u_char *php_parserr(u_char *cp, u_char *end, querybuf *answer, int type_t
n = ((int)cp[0]) & 0xFF;
cp++;
add_assoc_long(subarray, "masklen", n);
tp = (u_char*)name;
tp = (uint8_t*)name;
if (n > 15) {
have_v6_break = 1;
in_v6_break = 1;
@ -698,7 +698,7 @@ static u_char *php_parserr(u_char *cp, u_char *end, querybuf *answer, int type_t
if (n % 16 > 8) {
/* Partial short */
if (cp[0] != 0) {
if (tp > (u_char *)name) {
if (tp > (uint8_t *)name) {
in_v6_break = 0;
tp[0] = ':';
tp++;
@ -723,7 +723,7 @@ static u_char *php_parserr(u_char *cp, u_char *end, querybuf *answer, int type_t
CHECKCP(2);
GETSHORT(s, cp);
if (s != 0) {
if (tp > (u_char *)name) {
if (tp > (uint8_t *)name) {
in_v6_break = 0;
tp[0] = ':';
tp++;
@ -840,7 +840,7 @@ PHP_FUNCTION(dns_get_record)
#endif
HEADER *hp;
querybuf answer = {0};
u_char *cp = NULL, *end = NULL;
uint8_t *cp = NULL, *end = NULL;
int n, qd, an, ns = 0, ar = 0;
int type, first_query = 1, store_results = 1;
bool raw = 0;
@ -1072,7 +1072,7 @@ PHP_FUNCTION(dns_get_mx)
querybuf answer = {0};
char buf[MAXHOSTNAMELEN] = {0};
HEADER *hp;
u_char *cp, *end;
uint8_t *cp, *end;
int i;
#if defined(HAVE_DNS_SEARCH)
struct sockaddr_storage from;
@ -1116,7 +1116,7 @@ PHP_FUNCTION(dns_get_mx)
res_init();
#endif
i = php_dns_search(handle, hostname, C_IN, DNS_T_MX, answer.qb2, sizeof answer);
i = php_dns_search(handle, hostname, C_IN, DNS_T_MX, answer.qb2, sizeof(answer));
if (i < 0) {
php_dns_free_handle(handle);
RETURN_FALSE;

View File

@ -141,7 +141,7 @@ PHP_FUNCTION(dns_check_record)
/* }}} */
/* {{{ php_parserr */
static void php_parserr(PDNS_RECORD pRec, int type_to_fetch, int store, int raw, zval *subarray)
static void php_parserr(PDNS_RECORD pRec, int type_to_fetch, int store, bool raw, zval *subarray)
{
int type;
u_long ttl;
@ -271,7 +271,7 @@ static void php_parserr(PDNS_RECORD pRec, int type_to_fetch, int store, int raw,
for(i=0; i < 8; i++) {
if (out[i] != 0) {
if (tp > (u_char *)buf) {
if (tp > (uint8_t *)buf) {
in_v6_break = 0;
tp[0] = ':';
tp++;

View File

@ -159,7 +159,7 @@ static void qprintf(const char *, Char *);
PHPAPI int glob(const char *pattern, int flags, int (*errfunc)(const char *, int), glob_t *pglob)
{
const u_char *patnext;
const uint8_t *patnext;
int c;
Char *bufnext, *bufend, patbuf[MAXPATHLEN];
@ -170,7 +170,7 @@ PHPAPI int glob(const char *pattern, int flags, int (*errfunc)(const char *, int
flags |= GLOB_NOESCAPE;
#endif
patnext = (u_char *) pattern;
patnext = (uint8_t *) pattern;
if (!(flags & GLOB_APPEND)) {
pglob->gl_pathc = 0;
pglob->gl_pathv = NULL;
@ -625,14 +625,14 @@ static int glob3(Char *pathbuf, Char *pathbuf_last, Char *pathend, Char *pathend
else
readdirfunc = readdir;
while ((dp = (*readdirfunc)(dirp))) {
register u_char *sc;
register uint8_t *sc;
register Char *dc;
/* Initial DOT must be matched literally. */
if (dp->d_name[0] == DOT && *pattern != DOT)
continue;
dc = pathend;
sc = (u_char *) dp->d_name;
sc = (uint8_t *) dp->d_name;
while (dc < pathend_last && (*dc++ = *sc++) != EOS)
;
if (dc >= pathend_last) {