mirror of
https://github.com/curl/curl.git
synced 2026-04-14 22:51:53 +03:00
httpsrr/altsvc: eliminate size_t casts
Treat alpn raw data as unsigned chars, avoids size_t and char* casts. Add method to convert a struct Curl_str to an alpnid. Closes #19621
This commit is contained in:
parent
6c55dd0028
commit
ad9b12d411
4 changed files with 21 additions and 15 deletions
|
|
@ -66,6 +66,7 @@
|
|||
#include "sockaddr.h" /* required for Curl_sockaddr_storage */
|
||||
#include "curlx/inet_ntop.h"
|
||||
#include "curlx/inet_pton.h"
|
||||
#include "curlx/strparse.h"
|
||||
#include "vtls/vtls.h" /* for vtsl cfilters */
|
||||
#include "progress.h"
|
||||
#include "curlx/warnless.h"
|
||||
|
|
@ -81,23 +82,29 @@
|
|||
|
||||
#if !defined(CURL_DISABLE_ALTSVC) || defined(USE_HTTPSRR)
|
||||
|
||||
enum alpnid Curl_alpn2alpnid(const char *name, size_t len)
|
||||
enum alpnid Curl_alpn2alpnid(const unsigned char *name, size_t len)
|
||||
{
|
||||
if(len == 2) {
|
||||
if(curl_strnequal(name, "h1", 2))
|
||||
if(!memcmp(name, "h1", 2))
|
||||
return ALPN_h1;
|
||||
if(curl_strnequal(name, "h2", 2))
|
||||
if(!memcmp(name, "h2", 2))
|
||||
return ALPN_h2;
|
||||
if(curl_strnequal(name, "h3", 2))
|
||||
if(!memcmp(name, "h3", 2))
|
||||
return ALPN_h3;
|
||||
}
|
||||
else if(len == 8) {
|
||||
if(curl_strnequal(name, "http/1.1", 8))
|
||||
if(!memcmp(name, "http/1.1", 8))
|
||||
return ALPN_h1;
|
||||
}
|
||||
return ALPN_none; /* unknown, probably rubbish input */
|
||||
}
|
||||
|
||||
enum alpnid Curl_str2alpnid(const struct Curl_str *cstr)
|
||||
{
|
||||
return Curl_alpn2alpnid((const unsigned char *)curlx_str(cstr),
|
||||
curlx_strlen(cstr));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue