[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnurl] 259/264: doh: Constify some input pointers
From: |
gnunet |
Subject: |
[gnurl] 259/264: doh: Constify some input pointers |
Date: |
Thu, 30 Apr 2020 16:09:22 +0200 |
This is an automated email from the git hooks/post-receive script.
nikita pushed a commit to branch master
in repository gnurl.
commit fc0e29dd57bb0dc7bbf4d0e5c9638b01f7b6afc6
Author: Rikard Falkeborn <address@hidden>
AuthorDate: Mon Apr 27 12:07:34 2020 +0200
doh: Constify some input pointers
Closes #5306
---
lib/doh.c | 26 ++++++++++++++------------
lib/doh.h | 2 +-
tests/unit/unit1650.c | 8 ++++----
3 files changed, 19 insertions(+), 17 deletions(-)
diff --git a/lib/doh.c b/lib/doh.c
index dd2bbf125..10867cc34 100644
--- a/lib/doh.c
+++ b/lib/doh.c
@@ -174,7 +174,7 @@ UNITTEST DOHcode doh_encode(const char *host,
}
static size_t
-doh_write_cb(void *contents, size_t size, size_t nmemb, void *userp)
+doh_write_cb(const void *contents, size_t size, size_t nmemb, void *userp)
{
size_t realsize = size * nmemb;
struct dohresponse *mem = (struct dohresponse *)userp;
@@ -439,7 +439,7 @@ Curl_addrinfo *Curl_doh(struct connectdata *conn,
return NULL;
}
-static DOHcode skipqname(unsigned char *doh, size_t dohlen,
+static DOHcode skipqname(const unsigned char *doh, size_t dohlen,
unsigned int *indexp)
{
unsigned char length;
@@ -463,12 +463,12 @@ static DOHcode skipqname(unsigned char *doh, size_t
dohlen,
return DOH_OK;
}
-static unsigned short get16bit(unsigned char *doh, int index)
+static unsigned short get16bit(const unsigned char *doh, int index)
{
return (unsigned short)((doh[index] << 8) | doh[index + 1]);
}
-static unsigned int get32bit(unsigned char *doh, int index)
+static unsigned int get32bit(const unsigned char *doh, int index)
{
/* make clang and gcc optimize this to bswap by incrementing
the pointer first. */
@@ -480,7 +480,7 @@ static unsigned int get32bit(unsigned char *doh, int index)
return ( (unsigned)doh[0] << 24) | (doh[1] << 16) |(doh[2] << 8) | doh[3];
}
-static DOHcode store_a(unsigned char *doh, int index, struct dohentry *d)
+static DOHcode store_a(const unsigned char *doh, int index, struct dohentry *d)
{
/* silently ignore addresses over the limit */
if(d->numaddr < DOH_MAX_ADDR) {
@@ -492,7 +492,9 @@ static DOHcode store_a(unsigned char *doh, int index,
struct dohentry *d)
return DOH_OK;
}
-static DOHcode store_aaaa(unsigned char *doh, int index, struct dohentry *d)
+static DOHcode store_aaaa(const unsigned char *doh,
+ int index,
+ struct dohentry *d)
{
/* silently ignore addresses over the limit */
if(d->numaddr < DOH_MAX_ADDR) {
@@ -505,7 +507,7 @@ static DOHcode store_aaaa(unsigned char *doh, int index,
struct dohentry *d)
}
static DOHcode cnameappend(struct cnamestore *c,
- unsigned char *src,
+ const unsigned char *src,
size_t len)
{
if(!c->alloc) {
@@ -530,7 +532,7 @@ static DOHcode cnameappend(struct cnamestore *c,
return DOH_OK;
}
-static DOHcode store_cname(unsigned char *doh,
+static DOHcode store_cname(const unsigned char *doh,
size_t dohlen,
unsigned int index,
struct dohentry *d)
@@ -585,7 +587,7 @@ static DOHcode store_cname(unsigned char *doh,
return DOH_OK;
}
-static DOHcode rdata(unsigned char *doh,
+static DOHcode rdata(const unsigned char *doh,
size_t dohlen,
unsigned short rdlength,
unsigned short type,
@@ -635,7 +637,7 @@ static void init_dohentry(struct dohentry *de)
}
-UNITTEST DOHcode doh_decode(unsigned char *doh,
+UNITTEST DOHcode doh_decode(const unsigned char *doh,
size_t dohlen,
DNStype dnstype,
struct dohentry *d)
@@ -775,12 +777,12 @@ UNITTEST DOHcode doh_decode(unsigned char *doh,
#ifndef CURL_DISABLE_VERBOSE_STRINGS
static void showdoh(struct Curl_easy *data,
- struct dohentry *d)
+ const struct dohentry *d)
{
int i;
infof(data, "TTL: %u seconds\n", d->ttl);
for(i = 0; i < d->numaddr; i++) {
- struct dohaddr *a = &d->addr[i];
+ const struct dohaddr *a = &d->addr[i];
if(a->type == DNS_TYPE_A) {
infof(data, "DOH A: %u.%u.%u.%u\n",
a->ip.v4[0], a->ip.v4[1],
diff --git a/lib/doh.h b/lib/doh.h
index fc053eddf..97d459f09 100644
--- a/lib/doh.h
+++ b/lib/doh.h
@@ -99,7 +99,7 @@ DOHcode doh_encode(const char *host,
unsigned char *dnsp, /* buffer */
size_t len, /* buffer size */
size_t *olen); /* output length */
-DOHcode doh_decode(unsigned char *doh,
+DOHcode doh_decode(const unsigned char *doh,
size_t dohlen,
DNStype dnstype,
struct dohentry *d);
diff --git a/tests/unit/unit1650.c b/tests/unit/unit1650.c
index 35ac12c81..502bf9df0 100644
--- a/tests/unit/unit1650.c
+++ b/tests/unit/unit1650.c
@@ -185,7 +185,7 @@ UNITTEST_START
size_t len;
int u;
memset(&d, 0, sizeof(d));
- rc = doh_decode((unsigned char *)resp[i].packet, resp[i].size,
+ rc = doh_decode((const unsigned char *)resp[i].packet, resp[i].size,
resp[i].type, &d);
if(rc != resp[i].rc) {
fprintf(stderr, "resp %zu: Expected return code %d got %d\n", i,
@@ -241,7 +241,7 @@ UNITTEST_START
struct dohentry d;
int rc;
memset(&d, 0, sizeof(d));
- rc = doh_decode((unsigned char *)full49, i, DNS_TYPE_A, &d);
+ rc = doh_decode((const unsigned char *)full49, i, DNS_TYPE_A, &d);
if(!rc) {
/* none of them should work */
fprintf(stderr, "%zu: %d\n", i, rc);
@@ -253,7 +253,7 @@ UNITTEST_START
struct dohentry d;
int rc;
memset(&d, 0, sizeof(d));
- rc = doh_decode((unsigned char *)&full49[i], sizeof(full49)-i-1,
+ rc = doh_decode((const unsigned char *)&full49[i], sizeof(full49)-i-1,
DNS_TYPE_A, &d);
if(!rc) {
/* none of them should work */
@@ -266,7 +266,7 @@ UNITTEST_START
struct dohentry d;
struct dohaddr *a;
memset(&d, 0, sizeof(d));
- rc = doh_decode((unsigned char *)full49, sizeof(full49)-1,
+ rc = doh_decode((const unsigned char *)full49, sizeof(full49)-1,
DNS_TYPE_A, &d);
fail_if(d.numaddr != 1, "missing address");
a = &d.addr[0];
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [gnurl] 114/264: CI: increase Azure Pipelines timeouts due to performance issues, (continued)
- [gnurl] 114/264: CI: increase Azure Pipelines timeouts due to performance issues, gnunet, 2020/04/30
- [gnurl] 141/264: select: remove typecast from SOCKET_WRITABLE/READABLE macros, gnunet, 2020/04/30
- [gnurl] 122/264: CURLINFO_CONDITION_UNMET: return true for 304 http status code, gnunet, 2020/04/30
- [gnurl] 236/264: gnutls: bump lowest supported version to 3.1.10, gnunet, 2020/04/30
- [gnurl] 137/264: configure: remove use of -vec-report0 from CFLAGS with icc, gnunet, 2020/04/30
- [gnurl] 117/264: sockfilt: fix handling of ready closed sockets on Windows, gnunet, 2020/04/30
- [gnurl] 124/264: KNOWN_BUGS: fixed "USE_UNIX_SOCKETS on Windows", gnunet, 2020/04/30
- [gnurl] 154/264: CI/macos: convert CRLF to LF and align indentation, gnunet, 2020/04/30
- [gnurl] 152/264: server/resolve: remove AI_CANONNAME to make macos tell the truth, gnunet, 2020/04/30
- [gnurl] 213/264: tests/FILEFORMAT: converted to markdown and extended, gnunet, 2020/04/30
- [gnurl] 259/264: doh: Constify some input pointers,
gnunet <=
- [gnurl] 161/264: release-notes.pl: detect the start of the references in cleanup mode, gnunet, 2020/04/30
- [gnurl] 214/264: mime: properly check Content-Type even if it has parameters, gnunet, 2020/04/30
- [gnurl] 164/264: tests: add Windows compatible pidwait like pidkill and pidterm, gnunet, 2020/04/30
- [gnurl] 166/264: tests/server/util.c: use curl_off_t instead of long for pid, gnunet, 2020/04/30
- [gnurl] 167/264: compressed.d: stress that the headers are not modified, gnunet, 2020/04/30
- [gnurl] 165/264: tests: use Cygwin/msys PIDs for stunnel and sshd on Windows, gnunet, 2020/04/30
- [gnurl] 264/264: make gnurl-aux, gnunet, 2020/04/30
- [gnurl] 177/264: cirrus: no longer ignore test 504 which is working again, gnunet, 2020/04/30
- [gnurl] 180/264: tool: do not declare functions with Curl_ prefix, gnunet, 2020/04/30
- [gnurl] 229/264: http: free memory when Alt-Used header creation fails due to OOM, gnunet, 2020/04/30