Commit 5b1c7ef3 authored by Mark Andrews's avatar Mark Andrews
Browse files

4264. [bug] Check const of strchr/strrchr assignments match

                        argument's const status. [RT #41150]
parent 913d976e
4264. [bug] Check const of strchr/strrchr assignments match
argument's const status. [RT #41150]
4263. [contrib] Address compiler warnings in mysqldyn module. 4263. [contrib] Address compiler warnings in mysqldyn module.
[RT #41130] [RT #41130]
......
...@@ -58,7 +58,7 @@ dns_zone_t *zone = NULL; ...@@ -58,7 +58,7 @@ dns_zone_t *zone = NULL;
dns_zonetype_t zonetype = dns_zone_master; dns_zonetype_t zonetype = dns_zone_master;
static int dumpzone = 0; static int dumpzone = 0;
static const char *output_filename; static const char *output_filename;
static char *prog_name = NULL; static const char *prog_name = NULL;
static const dns_master_style_t *outputstyle = NULL; static const dns_master_style_t *outputstyle = NULL;
static enum { progmode_check, progmode_compile } progmode; static enum { progmode_check, progmode_compile } progmode;
......
...@@ -739,7 +739,7 @@ printgreeting(int argc, char **argv, dig_lookup_t *lookup) { ...@@ -739,7 +739,7 @@ printgreeting(int argc, char **argv, dig_lookup_t *lookup) {
*/ */
static void static void
plus_option(char *option, isc_boolean_t is_batchfile, plus_option(const char *option, isc_boolean_t is_batchfile,
dig_lookup_t *lookup) dig_lookup_t *lookup)
{ {
isc_result_t result; isc_result_t result;
...@@ -752,7 +752,7 @@ plus_option(char *option, isc_boolean_t is_batchfile, ...@@ -752,7 +752,7 @@ plus_option(char *option, isc_boolean_t is_batchfile,
strncpy(option_store, option, sizeof(option_store)); strncpy(option_store, option, sizeof(option_store));
option_store[sizeof(option_store)-1]=0; option_store[sizeof(option_store)-1]=0;
ptr = option_store; ptr = option_store;
cmd = next_token(&ptr,"="); cmd = next_token(&ptr, "=");
if (cmd == NULL) { if (cmd == NULL) {
printf(";; Invalid option %s\n", option_store); printf(";; Invalid option %s\n", option_store);
return; return;
...@@ -1406,7 +1406,7 @@ plus_option(char *option, isc_boolean_t is_batchfile, ...@@ -1406,7 +1406,7 @@ plus_option(char *option, isc_boolean_t is_batchfile,
invalid_option: invalid_option:
need_value: need_value:
fprintf(stderr, "Invalid option: +%s\n", fprintf(stderr, "Invalid option: +%s\n",
option); option);
usage(); usage();
} }
return; return;
...@@ -1636,14 +1636,14 @@ dash_option(char *option, char *next, dig_lookup_t **lookup, ...@@ -1636,14 +1636,14 @@ dash_option(char *option, char *next, dig_lookup_t **lookup,
value); value);
return (value_from_next); return (value_from_next);
case 'y': case 'y':
ptr = next_token(&value,":"); /* hmac type or name */ ptr = next_token(&value, ":"); /* hmac type or name */
if (ptr == NULL) { if (ptr == NULL) {
usage(); usage();
} }
ptr2 = next_token(&value, ":"); /* name or secret */ ptr2 = next_token(&value, ":"); /* name or secret */
if (ptr2 == NULL) if (ptr2 == NULL)
usage(); usage();
ptr3 = next_token(&value,":"); /* secret or NULL */ ptr3 = next_token(&value, ":"); /* secret or NULL */
if (ptr3 != NULL) { if (ptr3 != NULL) {
parse_hmac(ptr); parse_hmac(ptr);
ptr = ptr2; ptr = ptr2;
......
...@@ -463,7 +463,7 @@ append(const char *text, int len, char **p, char *end) { ...@@ -463,7 +463,7 @@ append(const char *text, int len, char **p, char *end) {
static isc_result_t static isc_result_t
reverse_octets(const char *in, char **p, char *end) { reverse_octets(const char *in, char **p, char *end) {
char *dot = strchr(in, '.'); const char *dot = strchr(in, '.');
int len; int len;
if (dot != NULL) { if (dot != NULL) {
isc_result_t result; isc_result_t result;
...@@ -1069,13 +1069,17 @@ parse_netprefix(isc_sockaddr_t **sap, const char *value) { ...@@ -1069,13 +1069,17 @@ parse_netprefix(isc_sockaddr_t **sap, const char *value) {
isc_uint32_t netmask = 0; isc_uint32_t netmask = 0;
char *slash = NULL; char *slash = NULL;
isc_boolean_t parsed = ISC_FALSE; isc_boolean_t parsed = ISC_FALSE;
char buf[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:XXX.XXX.XXX.XXX/128")];
if ((slash = strchr(value, '/'))) { if (strlcpy(buf, value, sizeof(buf)) >= sizeof(buf))
fatal("invalid prefix '%s'\n", value);
slash = strchr(buf, '/');
if (slash != NULL) {
*slash = '\0'; *slash = '\0';
result = isc_parse_uint32(&netmask, slash + 1, 10); result = isc_parse_uint32(&netmask, slash + 1, 10);
if (result != ISC_R_SUCCESS) { if (result != ISC_R_SUCCESS) {
*slash = '/'; fatal("invalid prefix length in '%s': %s\n",
fatal("invalid prefix length '%s': %s\n",
value, isc_result_totext(result)); value, isc_result_totext(result));
} }
} }
...@@ -1083,21 +1087,19 @@ parse_netprefix(isc_sockaddr_t **sap, const char *value) { ...@@ -1083,21 +1087,19 @@ parse_netprefix(isc_sockaddr_t **sap, const char *value) {
sa = isc_mem_allocate(mctx, sizeof(*sa)); sa = isc_mem_allocate(mctx, sizeof(*sa));
if (sa == NULL) if (sa == NULL)
fatal("out of memory"); fatal("out of memory");
if (inet_pton(AF_INET6, value, &in6) == 1) { if (inet_pton(AF_INET6, buf, &in6) == 1) {
isc_sockaddr_fromin6(sa, &in6, 0);
parsed = ISC_TRUE; parsed = ISC_TRUE;
isc_sockaddr_fromin6(sa, &in6, 0);
if (netmask == 0 || netmask > 128) if (netmask == 0 || netmask > 128)
netmask = 128; netmask = 128;
} else if (inet_pton(AF_INET, value, &in4) == 1) { } else if (inet_pton(AF_INET, buf, &in4) == 1) {
parsed = ISC_TRUE; parsed = ISC_TRUE;
isc_sockaddr_fromin(sa, &in4, 0); isc_sockaddr_fromin(sa, &in4, 0);
if (netmask == 0 || netmask > 32) if (netmask == 0 || netmask > 32)
netmask = 32; netmask = 32;
} else if (netmask != 0) { } else if (netmask != 0) {
char buf[64];
int i; int i;
strlcpy(buf, value, sizeof(buf));
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
strlcat(buf, ".0", sizeof(buf)); strlcat(buf, ".0", sizeof(buf));
if (inet_pton(AF_INET, buf, &in4) == 1) { if (inet_pton(AF_INET, buf, &in4) == 1) {
...@@ -1106,12 +1108,8 @@ parse_netprefix(isc_sockaddr_t **sap, const char *value) { ...@@ -1106,12 +1108,8 @@ parse_netprefix(isc_sockaddr_t **sap, const char *value) {
break; break;
} }
} }
} }
if (slash != NULL)
*slash = '/';
if (!parsed) if (!parsed)
fatal("invalid address '%s'", value); fatal("invalid address '%s'", value);
...@@ -1121,7 +1119,6 @@ parse_netprefix(isc_sockaddr_t **sap, const char *value) { ...@@ -1121,7 +1119,6 @@ parse_netprefix(isc_sockaddr_t **sap, const char *value) {
return (ISC_R_SUCCESS); return (ISC_R_SUCCESS);
} }
/* /*
* Parse HMAC algorithm specification * Parse HMAC algorithm specification
*/ */
......
...@@ -86,7 +86,8 @@ main(int argc, char **argv) { ...@@ -86,7 +86,8 @@ main(int argc, char **argv) {
#else #else
const char *engine = NULL; const char *engine = NULL;
#endif #endif
char *filename = NULL, *dir = NULL; char const *filename = NULL;
char *dir = NULL;
char newname[1024], oldname[1024]; char newname[1024], oldname[1024];
char keystr[DST_KEY_FORMATSIZE]; char keystr[DST_KEY_FORMATSIZE];
char *endp; char *endp;
......
...@@ -133,7 +133,8 @@ main(int argc, char **argv) { ...@@ -133,7 +133,8 @@ main(int argc, char **argv) {
#else #else
const char *engine = NULL; const char *engine = NULL;
#endif #endif
char *filename = NULL, *directory = NULL; const char *filename = NULL;
char *directory = NULL;
char newname[1024]; char newname[1024];
char keystr[DST_KEY_FORMATSIZE]; char keystr[DST_KEY_FORMATSIZE];
char *endp, *p; char *endp, *p;
......
...@@ -2701,7 +2701,8 @@ get_ticket_realm(isc_mem_t *mctx) { ...@@ -2701,7 +2701,8 @@ get_ticket_realm(isc_mem_t *mctx) {
krb5_error_code rc; krb5_error_code rc;
krb5_ccache ccache; krb5_ccache ccache;
krb5_principal princ; krb5_principal princ;
char *name, *ticket_realm; char *name;
const char * ticket_realm;
rc = krb5_init_context(&ctx); rc = krb5_init_context(&ctx);
if (rc != 0) if (rc != 0)
......
...@@ -367,7 +367,7 @@ main(int argc, char *argv[]) { ...@@ -367,7 +367,7 @@ main(int argc, char *argv[]) {
dns_name_t *fname; dns_name_t *fname;
unsigned int options = 0, zcoptions; unsigned int options = 0, zcoptions;
isc_time_t start, finish; isc_time_t start, finish;
char *origintext; const char *origintext;
dbinfo *dbi; dbinfo *dbi;
dns_dbversion_t *version; dns_dbversion_t *version;
dns_name_t *origin; dns_name_t *origin;
......
...@@ -118,7 +118,7 @@ nsecify(char *filename) { ...@@ -118,7 +118,7 @@ nsecify(char *filename) {
dns_db_t *db; dns_db_t *db;
dns_dbversion_t *wversion; dns_dbversion_t *wversion;
dns_dbnode_t *node, *nextnode; dns_dbnode_t *node, *nextnode;
char *origintext; const char *origintext;
dns_fixedname_t fname, fnextname; dns_fixedname_t fname, fnextname;
dns_name_t *name, *nextname, *target; dns_name_t *name, *nextname, *target;
isc_buffer_t b; isc_buffer_t b;
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#include <dns/fixedname.h> #include <dns/fixedname.h>
#include <dns/result.h> #include <dns/result.h>
char *progname; const char *progname;
isc_mem_t *mctx; isc_mem_t *mctx;
#define DNSNAMELEN 255 #define DNSNAMELEN 255
......
...@@ -88,7 +88,7 @@ ...@@ -88,7 +88,7 @@
static isc_mem_t *mctx; static isc_mem_t *mctx;
static dns_requestmgr_t *requestmgr; static dns_requestmgr_t *requestmgr;
static char *batchname; static const char *batchname;
static FILE *batchfp; static FILE *batchfp;
static isc_boolean_t have_ipv4 = ISC_FALSE; static isc_boolean_t have_ipv4 = ISC_FALSE;
static isc_boolean_t have_ipv6 = ISC_FALSE; static isc_boolean_t have_ipv6 = ISC_FALSE;
...@@ -906,13 +906,16 @@ parse_netprefix(isc_sockaddr_t **sap, const char *value) { ...@@ -906,13 +906,16 @@ parse_netprefix(isc_sockaddr_t **sap, const char *value) {
isc_uint32_t netmask = 0; isc_uint32_t netmask = 0;
char *slash = NULL; char *slash = NULL;
isc_boolean_t parsed = ISC_FALSE; isc_boolean_t parsed = ISC_FALSE;
char buf[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:XXX.XXX.XXX.XXX/128")];
if ((slash = strchr(value, '/'))) { if (strlcpy(buf, value, sizeof(buf)) >= sizeof(buf))
*slash = '\0'; fatal("invalid prefix '%s'\n", value);
slash = strchr(buf, '/');
if (slash != NULL) {
result = isc_parse_uint32(&netmask, slash + 1, 10); result = isc_parse_uint32(&netmask, slash + 1, 10);
if (result != ISC_R_SUCCESS) { if (result != ISC_R_SUCCESS) {
*slash = '/'; fatal("invalid prefix length in '%s': %s\n",
fatal("invalid prefix length '%s': %s\n",
value, isc_result_totext(result)); value, isc_result_totext(result));
} }
} }
...@@ -920,21 +923,19 @@ parse_netprefix(isc_sockaddr_t **sap, const char *value) { ...@@ -920,21 +923,19 @@ parse_netprefix(isc_sockaddr_t **sap, const char *value) {
sa = isc_mem_allocate(mctx, sizeof(*sa)); sa = isc_mem_allocate(mctx, sizeof(*sa));
if (sa == NULL) if (sa == NULL)
fatal("out of memory"); fatal("out of memory");
if (inet_pton(AF_INET6, value, &in6) == 1) { if (inet_pton(AF_INET6, buf, &in6) == 1) {
isc_sockaddr_fromin6(sa, &in6, 0);
parsed = ISC_TRUE; parsed = ISC_TRUE;
isc_sockaddr_fromin6(sa, &in6, 0);
if (netmask == 0 || netmask > 128) if (netmask == 0 || netmask > 128)
netmask = 128; netmask = 128;
} else if (inet_pton(AF_INET, value, &in4) == 1) { } else if (inet_pton(AF_INET, buf, &in4) == 1) {
parsed = ISC_TRUE; parsed = ISC_TRUE;
isc_sockaddr_fromin(sa, &in4, 0); isc_sockaddr_fromin(sa, &in4, 0);
if (netmask == 0 || netmask > 32) if (netmask == 0 || netmask > 32)
netmask = 32; netmask = 32;
} else if (netmask != 0) { } else if (netmask != 0) {
char buf[64];
int i; int i;
strlcpy(buf, value, sizeof(buf));
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
strlcat(buf, ".0", sizeof(buf)); strlcat(buf, ".0", sizeof(buf));
if (inet_pton(AF_INET, buf, &in4) == 1) { if (inet_pton(AF_INET, buf, &in4) == 1) {
...@@ -946,9 +947,6 @@ parse_netprefix(isc_sockaddr_t **sap, const char *value) { ...@@ -946,9 +947,6 @@ parse_netprefix(isc_sockaddr_t **sap, const char *value) {
} }
if (slash != NULL)
*slash = '/';
if (!parsed) if (!parsed)
fatal("invalid address '%s'", value); fatal("invalid address '%s'", value);
...@@ -973,7 +971,7 @@ append(const char *text, int len, char **p, char *end) { ...@@ -973,7 +971,7 @@ append(const char *text, int len, char **p, char *end) {
static isc_result_t static isc_result_t
reverse_octets(const char *in, char **p, char *end) { reverse_octets(const char *in, char **p, char *end) {
char *dot = strchr(in, '.'); const char *dot = strchr(in, '.');
int len; int len;
if (dot != NULL) { if (dot != NULL) {
isc_result_t result; isc_result_t result;
...@@ -989,7 +987,8 @@ reverse_octets(const char *in, char **p, char *end) { ...@@ -989,7 +987,8 @@ reverse_octets(const char *in, char **p, char *end) {
} }
static void static void
get_reverse(char *reverse, size_t len, char *value, isc_boolean_t ip6_int) get_reverse(char *reverse, size_t len, const char *value,
isc_boolean_t ip6_int)
{ {
int r; int r;
isc_result_t result; isc_result_t result;
...@@ -1515,13 +1514,14 @@ plus_option(char *option, struct query *query, isc_boolean_t global) ...@@ -1515,13 +1514,14 @@ plus_option(char *option, struct query *query, isc_boolean_t global)
static const char *single_dash_opts = "46hiv"; static const char *single_dash_opts = "46hiv";
/*static const char *dash_opts = "46bcfhiptvx";*/ /*static const char *dash_opts = "46bcfhiptvx";*/
static isc_boolean_t static isc_boolean_t
dash_option(char *option, char *next, struct query *query, dash_option(const char *option, char *next, struct query *query,
isc_boolean_t global, isc_boolean_t *setname) isc_boolean_t global, isc_boolean_t *setname)
{ {
char opt, *value; char opt;
const char *value;
isc_result_t result; isc_result_t result;
isc_boolean_t value_from_next; isc_boolean_t value_from_next;
isc_textregion_t tr; isc_consttextregion_t tr;
dns_rdatatype_t rdtype; dns_rdatatype_t rdtype;
dns_rdataclass_t rdclass; dns_rdataclass_t rdclass;
char textname[MXNAME]; char textname[MXNAME];
......
...@@ -623,7 +623,7 @@ BN_fromhex(BIGNUM *b, const char *str) { ...@@ -623,7 +623,7 @@ BN_fromhex(BIGNUM *b, const char *str) {
RUNTIME_CHECK(strlen(str) < 1024U && strlen(str) % 2 == 0U); RUNTIME_CHECK(strlen(str) < 1024U && strlen(str) % 2 == 0U);
for (i = 0; i < strlen(str); i += 2) { for (i = 0; i < strlen(str); i += 2) {
char *s; const char *s;
unsigned int high, low; unsigned int high, low;
s = strchr(hexdigits, tolower((unsigned char)str[i])); s = strchr(hexdigits, tolower((unsigned char)str[i]));
......
...@@ -1398,8 +1398,7 @@ opensslrsa_fromlabel(dst_key_t *key, const char *engine, const char *label, ...@@ -1398,8 +1398,7 @@ opensslrsa_fromlabel(dst_key_t *key, const char *engine, const char *label,
UNUSED(pin); UNUSED(pin);
if (engine == NULL) { if (engine == NULL) {
colon = strchr(label, ':'); if (strchr(label, ':') == NULL)
if (colon == NULL)
DST_RET(DST_R_NOENGINE); DST_RET(DST_R_NOENGINE);
tmpengine = isc_mem_strdup(key->mctx, label); tmpengine = isc_mem_strdup(key->mctx, label);
if (tmpengine == NULL) if (tmpengine == NULL)
......
...@@ -18209,7 +18209,7 @@ dns_zone_keydone(dns_zone_t *zone, const char *keystr) { ...@@ -18209,7 +18209,7 @@ dns_zone_keydone(dns_zone_t *zone, const char *keystr) {
kd->all = ISC_TRUE; kd->all = ISC_TRUE;
else { else {
isc_textregion_t r; isc_textregion_t r;
char *algstr; const char *algstr;
dns_keytag_t keyid; dns_keytag_t keyid;
dns_secalg_t alg; dns_secalg_t alg;
size_t n; size_t n;
......
...@@ -170,7 +170,7 @@ base32_decode_init(base32_decode_ctx_t *ctx, int length, const char base[], ...@@ -170,7 +170,7 @@ base32_decode_init(base32_decode_ctx_t *ctx, int length, const char base[],
static inline isc_result_t static inline isc_result_t
base32_decode_char(base32_decode_ctx_t *ctx, int c) { base32_decode_char(base32_decode_ctx_t *ctx, int c) {
char *s; const char *s;
unsigned int last; unsigned int last;
if (ctx->seen_end) if (ctx->seen_end)
......
...@@ -118,7 +118,7 @@ base64_decode_init(base64_decode_ctx_t *ctx, int length, isc_buffer_t *target) ...@@ -118,7 +118,7 @@ base64_decode_init(base64_decode_ctx_t *ctx, int length, isc_buffer_t *target)
static inline isc_result_t static inline isc_result_t
base64_decode_char(base64_decode_ctx_t *ctx, int c) { base64_decode_char(base64_decode_ctx_t *ctx, int c) {
char *s; const char *s;
if (ctx->seen_end) if (ctx->seen_end)
return (ISC_R_BADBASE64); return (ISC_R_BADBASE64);
......
...@@ -96,7 +96,7 @@ static char endopt = '\0'; ...@@ -96,7 +96,7 @@ static char endopt = '\0';
int int
isc_commandline_parse(int argc, char * const *argv, const char *options) { isc_commandline_parse(int argc, char * const *argv, const char *options) {
static char *place = ENDOPT; static char *place = ENDOPT;
char *option; /* Index into *options of option. */ const char *option; /* Index into *options of option. */
REQUIRE(argc >= 0 && argv != NULL && options != NULL); REQUIRE(argc >= 0 && argv != NULL && options != NULL);
......
...@@ -95,7 +95,7 @@ hex_decode_init(hex_decode_ctx_t *ctx, int length, isc_buffer_t *target) ...@@ -95,7 +95,7 @@ hex_decode_init(hex_decode_ctx_t *ctx, int length, isc_buffer_t *target)
static inline isc_result_t static inline isc_result_t
hex_decode_char(hex_decode_ctx_t *ctx, int c) { hex_decode_char(hex_decode_ctx_t *ctx, int c) {
char *s; const char *s;
if ((s = strchr(hex, toupper(c))) == NULL) if ((s = strchr(hex, toupper(c))) == NULL)
return (ISC_R_BADHEX); return (ISC_R_BADHEX);
......
...@@ -315,8 +315,8 @@ isc_file_safecreate(const char *filename, FILE **fp); ...@@ -315,8 +315,8 @@ isc_file_safecreate(const char *filename, FILE **fp);
*/ */
isc_result_t isc_result_t
isc_file_splitpath(isc_mem_t *mctx, char *path, isc_file_splitpath(isc_mem_t *mctx, const char *path,
char **dirname, char **basename); char **dirname, char const **basename);
/*%< /*%<
* Split a path into dirname and basename. If 'path' contains no slash * Split a path into dirname and basename. If 'path' contains no slash
* (or, on windows, backslash), then '*dirname' is set to ".". * (or, on windows, backslash), then '*dirname' is set to ".".
......
...@@ -56,14 +56,14 @@ ...@@ -56,14 +56,14 @@
#include <isc/string.h> #include <isc/string.h>
#include <isc/util.h> #include <isc/util.h>
static char digits[] = "0123456789abcdefghijklmnoprstuvwxyz"; static const char digits[] = "0123456789abcdefghijklmnoprstuvwxyz";
isc_uint64_t isc_uint64_t
isc_string_touint64(char *source, char **end, int base) { isc_string_touint64(char *source, char **end, int base) {
isc_uint64_t tmp; isc_uint64_t tmp;
isc_uint64_t overflow; isc_uint64_t overflow;
char *s = source; char *s = source;
char *o; const char *o;
char c; char c;
if ((base < 0) || (base == 1) || (base > 36)) { if ((base < 0) || (base == 1) || (base > 36)) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment