Turn some strlcats into strlcpy
This commit is contained in:
parent
90f2c1f456
commit
3e3f989d45
|
@ -357,16 +357,17 @@ static size_t frontend_win32_get_os(char *s, size_t len, int *major, int *minor)
|
|||
* string manipulation. */
|
||||
|
||||
_len = strlcpy(s, str_ProductName, len);
|
||||
if (!string_is_empty(arch))
|
||||
|
||||
if (!string_is_empty(arch))
|
||||
{
|
||||
_len += strlcat(s, " ", len);
|
||||
_len += strlcat(s, arch, len);
|
||||
_len += strlcpy(s + _len, " ", len - _len);
|
||||
_len += strlcpy(s + _len, arch, len - _len);
|
||||
}
|
||||
_len = strlcat(s, " ", len);
|
||||
_len = strlcat(s, str_DisplayVersion, len);
|
||||
_len = strlcat(s, " (", len);
|
||||
_len = strlcat(s, str_LCUVer, len);
|
||||
_len = strlcat(s, ")", len);
|
||||
_len = strlcpy(s + _len, " ", len - _len);
|
||||
_len = strlcpy(s + _len, str_DisplayVersion, len - _len);
|
||||
_len = strlcpy(s + _len, " (", len - _len);
|
||||
_len = strlcpy(s + _len, str_LCUVer, len - _len);
|
||||
_len = strlcpy(s + _len, ")", len - _len);
|
||||
|
||||
*major = 10;
|
||||
*minor = 0;
|
||||
|
|
|
@ -273,48 +273,50 @@ static bool parse_desc_node(rxml_node_t *node,
|
|||
{
|
||||
rxml_node_t *child = node->children;
|
||||
|
||||
if (!child)
|
||||
return false;
|
||||
|
||||
/* We only care for services. */
|
||||
if (string_is_equal_case_insensitive(node->name, "service"))
|
||||
if (child)
|
||||
{
|
||||
rxml_node_t *service_type = NULL;
|
||||
rxml_node_t *control_url = NULL;
|
||||
/* We only care for services. */
|
||||
if (string_is_equal_case_insensitive(node->name, "service"))
|
||||
{
|
||||
rxml_node_t *service_type = NULL;
|
||||
rxml_node_t *control_url = NULL;
|
||||
|
||||
do
|
||||
{
|
||||
if (string_is_equal_case_insensitive(child->name, "serviceType"))
|
||||
service_type = child;
|
||||
else if (string_is_equal_case_insensitive(child->name, "controlURL"))
|
||||
control_url = child;
|
||||
if (service_type && control_url)
|
||||
break;
|
||||
} while ((child = child->next));
|
||||
|
||||
if (service_type && control_url)
|
||||
{
|
||||
/* These two are the only IGD service types we can work with. */
|
||||
if ( strstr(service_type->data, ":WANIPConnection:")
|
||||
|| strstr(service_type->data, ":WANPPPConnection:"))
|
||||
{
|
||||
if (build_control_url(control_url, device))
|
||||
{
|
||||
strlcpy(device->service_type, service_type->data,
|
||||
sizeof(device->service_type));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* XML recursion */
|
||||
do
|
||||
{
|
||||
if (string_is_equal_case_insensitive(child->name, "serviceType"))
|
||||
service_type = child;
|
||||
else if (string_is_equal_case_insensitive(child->name, "controlURL"))
|
||||
control_url = child;
|
||||
if (service_type && control_url)
|
||||
break;
|
||||
if (parse_desc_node(child, device))
|
||||
return true;
|
||||
} while ((child = child->next));
|
||||
|
||||
if (!service_type || !control_url)
|
||||
return false;
|
||||
|
||||
/* These two are the only IGD service types we can work with. */
|
||||
if (!strstr(service_type->data, ":WANIPConnection:") &&
|
||||
!strstr(service_type->data, ":WANPPPConnection:"))
|
||||
return false;
|
||||
if (!build_control_url(control_url, device))
|
||||
return false;
|
||||
|
||||
strlcpy(device->service_type, service_type->data,
|
||||
sizeof(device->service_type));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* XML recursion */
|
||||
do
|
||||
{
|
||||
if (parse_desc_node(child, device))
|
||||
return true;
|
||||
} while ((child = child->next));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -667,9 +667,9 @@ static bool netplay_lan_ad_server(netplay_t *netplay)
|
|||
static uint32_t netplay_impl_magic(void)
|
||||
{
|
||||
size_t i;
|
||||
uint32_t res = 0;
|
||||
const char *ver = PACKAGE_VERSION;
|
||||
size_t _len = strlen(ver);
|
||||
uint32_t res = 0;
|
||||
const char *ver = PACKAGE_VERSION;
|
||||
size_t _len = strlen(ver);
|
||||
|
||||
for (i = 0; i < _len; i++)
|
||||
res ^= ver[i] << (i & 0xf);
|
||||
|
@ -1439,7 +1439,6 @@ static bool netplay_handshake_pre_nick(netplay_t *netplay,
|
|||
ssize_t recvd;
|
||||
struct nick_buf_s nick_buf;
|
||||
int32_t ping = 0;
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
RECV(&nick_buf, sizeof(nick_buf)) {}
|
||||
|
||||
|
@ -1471,6 +1470,8 @@ static bool netplay_handshake_pre_nick(netplay_t *netplay,
|
|||
|
||||
if (netplay->is_server)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
if (!netplay_handshake_nick(netplay, connection))
|
||||
return false;
|
||||
|
||||
|
@ -4936,14 +4937,16 @@ static void netplay_handle_play_spectate(netplay_t *netplay,
|
|||
|
||||
if (connection)
|
||||
{
|
||||
bool slave = false;
|
||||
settings_t *settings = config_get_ptr();
|
||||
bool slave = false;
|
||||
settings_t *settings = config_get_ptr();
|
||||
bool netplay_allow_slaves = settings->bools.netplay_allow_slaves;
|
||||
bool netplay_require_slaves = settings->bools.netplay_require_slaves;
|
||||
|
||||
/* Slave mode unused when core uses netpacket interface */
|
||||
if ( settings->bools.netplay_allow_slaves
|
||||
if ( netplay_allow_slaves
|
||||
&& netplay->modus != NETPLAY_MODUS_CORE_PACKET_INTERFACE)
|
||||
{
|
||||
if (settings->bools.netplay_require_slaves)
|
||||
if (netplay_require_slaves)
|
||||
slave = true;
|
||||
else if (mode & NETPLAY_CMD_PLAY_BIT_SLAVE)
|
||||
slave = true;
|
||||
|
@ -5005,7 +5008,7 @@ static void netplay_handle_play_spectate(netplay_t *netplay,
|
|||
mode = NETPLAY_CMD_MODE_BIT_PLAYING;
|
||||
|
||||
netplay->self_devices = devices;
|
||||
netplay->self_mode = NETPLAY_CONNECTION_PLAYING;
|
||||
netplay->self_mode = NETPLAY_CONNECTION_PLAYING;
|
||||
|
||||
netplay_announce_play_spectate(netplay, NULL,
|
||||
netplay->self_mode, devices, -1, client_num);
|
||||
|
|
12
save.c
12
save.c
|
@ -401,18 +401,20 @@ static bool content_load_ram_file(unsigned slot)
|
|||
static bool dump_to_file_desperate(const void *data,
|
||||
size_t len, unsigned type)
|
||||
{
|
||||
size_t _len;
|
||||
char path[PATH_MAX_LENGTH + 256 + 32];
|
||||
path [0] = '\0';
|
||||
path[0] = '\0';
|
||||
_len = fill_pathname_application_data(path,
|
||||
sizeof(path));
|
||||
|
||||
if (fill_pathname_application_data(path,
|
||||
sizeof(path)))
|
||||
if (_len)
|
||||
{
|
||||
size_t _len;
|
||||
time_t time_;
|
||||
struct tm tm_;
|
||||
|
||||
time(&time_);
|
||||
rtime_localtime(&time_, &tm_);
|
||||
_len = strlcat(path, "/RetroArch-recovery-", sizeof(path));
|
||||
_len += strlcpy(path + _len, "/RetroArch-recovery-", sizeof(path) - _len);
|
||||
_len += snprintf(path + _len, sizeof(path) - _len, "%u", type);
|
||||
strftime(path + _len, sizeof(path) - _len,
|
||||
"%Y-%m-%d-%H-%M-%S", &tm_);
|
||||
|
|
Loading…
Reference in New Issue