mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 21:32:45 +00:00
Use STRLEN_CONST where possible; and don't needlessly do strlen
twice
This commit is contained in:
parent
12012b5041
commit
f84c6ec8cd
@ -124,19 +124,21 @@ static int GLXExtensionSupported(Display *dpy, const char *extension)
|
|||||||
const char *extensionsString = glXQueryExtensionsString(dpy, DefaultScreen(dpy));
|
const char *extensionsString = glXQueryExtensionsString(dpy, DefaultScreen(dpy));
|
||||||
const char *client_extensions = glXGetClientString(dpy, GLX_EXTENSIONS);
|
const char *client_extensions = glXGetClientString(dpy, GLX_EXTENSIONS);
|
||||||
const char *pos = strstr(extensionsString, extension);
|
const char *pos = strstr(extensionsString, extension);
|
||||||
|
size_t pos_ext_len = strlen(extension);
|
||||||
|
|
||||||
if ( pos &&
|
if ( pos &&
|
||||||
(pos == extensionsString || pos[-1] == ' ') &&
|
(pos == extensionsString || pos[-1] == ' ') &&
|
||||||
(pos[strlen(extension)] == ' ' || pos[strlen(extension)] == '\0')
|
(pos[pos_ext_len] == ' ' || pos[pos_ext_len] == '\0')
|
||||||
)
|
)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
pos = strstr(client_extensions, extension);
|
pos = strstr(client_extensions, extension);
|
||||||
|
pos_ext_len = strlen(extension);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
pos &&
|
pos &&
|
||||||
(pos == extensionsString || pos[-1] == ' ') &&
|
(pos == extensionsString || pos[-1] == ' ') &&
|
||||||
(pos[strlen(extension)] == ' ' || pos[strlen(extension)] == '\0')
|
(pos[pos_ext_len] == ' ' || pos[pos_ext_len] == '\0')
|
||||||
)
|
)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
@ -24,8 +24,11 @@
|
|||||||
#include <net/net_socket.h>
|
#include <net/net_socket.h>
|
||||||
#include <encodings/base64.h>
|
#include <encodings/base64.h>
|
||||||
#include <streams/file_stream.h>
|
#include <streams/file_stream.h>
|
||||||
|
#include <string/stdstring.h>
|
||||||
|
|
||||||
#include "../../deps/bearssl-0.6/inc/bearssl.h"
|
#include "../../deps/bearssl-0.6/inc/bearssl.h"
|
||||||
|
|
||||||
|
/* TODO/FIXME - static global variables */
|
||||||
static br_x509_trust_anchor TAs[500] = {};
|
static br_x509_trust_anchor TAs[500] = {};
|
||||||
static size_t TAs_NUM = 0;
|
static size_t TAs_NUM = 0;
|
||||||
|
|
||||||
@ -113,16 +116,17 @@ static void append_certs_pem_x509(char * certs_pem)
|
|||||||
void * cert_bin;
|
void * cert_bin;
|
||||||
int cert_bin_len;
|
int cert_bin_len;
|
||||||
|
|
||||||
while (true)
|
for (;;)
|
||||||
{
|
{
|
||||||
cert = strstr(cert_end, "-----BEGIN CERTIFICATE-----");
|
cert = strstr(cert_end, "-----BEGIN CERTIFICATE-----");
|
||||||
if (!cert) break;
|
if (!cert)
|
||||||
cert += strlen("-----BEGIN CERTIFICATE-----");
|
break;
|
||||||
cert_end = strstr(cert, "-----END CERTIFICATE-----");
|
cert += STRLEN_CONST("-----BEGIN CERTIFICATE-----");
|
||||||
|
cert_end = strstr(cert, "-----END CERTIFICATE-----");
|
||||||
|
|
||||||
*cert_end = '\0';
|
*cert_end = '\0';
|
||||||
cert = delete_linebreaks(cert);
|
cert = delete_linebreaks(cert);
|
||||||
|
|
||||||
cert_bin = unbase64(cert, cert_end-cert, &cert_bin_len);
|
cert_bin = unbase64(cert, cert_end-cert, &cert_bin_len);
|
||||||
append_cert_x509(cert_bin, cert_bin_len);
|
append_cert_x509(cert_bin, cert_bin_len);
|
||||||
free(cert_bin);
|
free(cert_bin);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user