mirror of
https://github.com/libretro/RetroArch
synced 2025-02-20 15:40:44 +00:00
Prevent more strlcats that are quite trivial
This commit is contained in:
parent
d01ae6929d
commit
5024b77492
@ -1295,20 +1295,25 @@ void fill_pathname_application_path(char *s, size_t len)
|
||||
CFStringRef bundle_path = CFURLCopyPath(bundle_url);
|
||||
CFStringGetCString(bundle_path, s, len, kCFStringEncodingUTF8);
|
||||
#ifdef HAVE_COCOATOUCH
|
||||
// This needs to be done so that the path becomes /private/var/... and this
|
||||
// is used consistently throughout for the iOS bundle path
|
||||
char resolved_bundle_dir_buf[PATH_MAX_LENGTH] = {0};
|
||||
if (realpath(s, resolved_bundle_dir_buf))
|
||||
{
|
||||
strlcpy(s,resolved_bundle_dir_buf, len);
|
||||
strlcat(s,"/",len);
|
||||
}
|
||||
{
|
||||
/* This needs to be done so that the path becomes
|
||||
* /private/var/... and this
|
||||
* is used consistently throughout for the iOS bundle path */
|
||||
char resolved_bundle_dir_buf[PATH_MAX_LENGTH] = {0};
|
||||
if (realpath(s, resolved_bundle_dir_buf))
|
||||
{
|
||||
size_t copied = strlcpy(s,resolved_bundle_dir_buf, len);
|
||||
s[copied] = '/';
|
||||
s[copied+1] = '\0';
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
CFRelease(bundle_path);
|
||||
CFRelease(bundle_url);
|
||||
#ifndef HAVE_COCOATOUCH
|
||||
// Not sure what this does but it breaks stuff for iOS so skipping
|
||||
/* Not sure what this does but it breaks
|
||||
* stuff for iOS, so skipping */
|
||||
retro_assert(strlcat(s, "nobin", len) < len);
|
||||
#endif
|
||||
return;
|
||||
|
@ -59,15 +59,20 @@ static INLINE bool string_is_equal(const char *a, const char *b)
|
||||
#define string_add_glob_open(s, size) strlcat((s), "glob('*", (size))
|
||||
#define string_add_glob_close(s, size) strlcat((s), "*')", (size))
|
||||
|
||||
#define string_add_pair_close_fast(s, size) \
|
||||
(s)[size] = ')'; \
|
||||
(s)[size+1] = '\0'
|
||||
|
||||
#define string_is_not_equal_fast(a, b, size) (memcmp(a, b, size) != 0)
|
||||
#define string_is_equal_fast(a, b, size) (memcmp(a, b, size) == 0)
|
||||
|
||||
static INLINE void string_add_between_pairs(char *s, const char *str,
|
||||
size_t size)
|
||||
{
|
||||
size_t copied;
|
||||
string_add_pair_open(s, size);
|
||||
strlcat(s, str, size);
|
||||
string_add_pair_close(s, size);
|
||||
copied = strlcat(s, str, size);
|
||||
string_add_pair_close_fast(s, copied);
|
||||
}
|
||||
|
||||
static INLINE bool string_is_equal_case_insensitive(const char *a,
|
||||
|
@ -176,14 +176,16 @@ int CreateSubfolder(const char * fullpath)
|
||||
|
||||
{
|
||||
char parentpath[strlen(dirnoslash)+2];
|
||||
strcpy(parentpath, dirnoslash);
|
||||
char * ptr = strrchr(parentpath, '/');
|
||||
size_t copied = strcpy(parentpath, dirnoslash);
|
||||
char * ptr = strrchr(parentpath, '/');
|
||||
|
||||
if (!ptr)
|
||||
{
|
||||
/* Device root directory (must be with '/') */
|
||||
strcat(parentpath, "/");
|
||||
struct stat filestat;
|
||||
/* Device root directory (must be with '/') */
|
||||
parentpath[copied] = '/';
|
||||
parentpath[copied+1] = '\0';
|
||||
|
||||
if (stat(parentpath, &filestat) == 0)
|
||||
return 1;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user