Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions ext/snmp/snmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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?
Expand Down
22 changes: 11 additions & 11 deletions ext/standard/dns.c
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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++;
Expand Down Expand Up @@ -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;
Expand All @@ -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++;
Expand All @@ -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++;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions ext/standard/dns_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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++;
Expand Down
8 changes: 4 additions & 4 deletions win32/glob.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand All @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down