Don't NULL-terminate string if we pass it to strlcpy and/or a

file_path function that calls strlcpy under the hood
This commit is contained in:
libretroadmin 2022-07-24 06:22:35 +02:00
parent 69a2d124c0
commit 5c98caa7fd
5 changed files with 10 additions and 30 deletions

View File

@ -2306,8 +2306,6 @@ static void materialui_refresh_playlist_icon_list(
const char *playlist_file = NULL;
char image_file[PATH_MAX_LENGTH];
image_file[0] = '\0';
/* We used malloc() to create the icons
* array - ensure struct members are
* correctly initialised */

View File

@ -4244,8 +4244,6 @@ static void ozone_init_horizontal_list(ozone_handle_t *ozone,
char *console_name = NULL;
const char *playlist_file = ozone->horizontal_list.list[i].path;
playlist_file_noext[0] = '\0';
if (!playlist_file)
{
file_list_set_alt_at_offset(&ozone->horizontal_list, i, NULL);
@ -4377,8 +4375,6 @@ static void ozone_context_reset_horizontal_list(ozone_handle_t *ozone)
strlcpy(icons_path, ozone->icons_path, sizeof(icons_path));
sysname[0] = texturepath[0] = content_texturepath[0] = '\0';
fill_pathname_base(sysname, path, sizeof(sysname));
path_remove_extension(sysname);
@ -4413,7 +4409,7 @@ static void ozone_context_reset_horizontal_list(ozone_handle_t *ozone)
fill_pathname_join_delim(sysname, sysname,
"content.png", '-', sizeof(sysname));
strlcat(content_texturepath, icons_path, sizeof(content_texturepath));
strlcpy(content_texturepath, icons_path, sizeof(content_texturepath));
strlcat(content_texturepath, PATH_DEFAULT_SLASH(), sizeof(content_texturepath));
strlcat(content_texturepath, sysname, sizeof(content_texturepath));
@ -7863,7 +7859,7 @@ static void ozone_set_layout(
bool font_inited = false;
float scale_factor = ozone->last_scale_factor;
font_path[0] = s1[0]= '\0';
s1[0] = '\0';
/* Calculate dimensions */
ozone->dimensions.header_height = HEADER_HEIGHT * scale_factor;
@ -8036,7 +8032,6 @@ static void ozone_context_reset(void *data, bool is_threaded)
for (i = 0; i < OZONE_TEXTURE_LAST; i++)
{
char filename[64];
filename[0] = '\0';
#if 0
if (i == OZONE_TEXTURE_DISCORD_OWN_AVATAR && discord_avatar_is_ready())
strlcpy(filename, discord_get_own_avatar(), sizeof(filename));
@ -8071,7 +8066,6 @@ static void ozone_context_reset(void *data, bool is_threaded)
for (i = 0; i < OZONE_TAB_TEXTURE_LAST; i++)
{
char filename[64];
filename[0] = '\0';
strlcpy(filename,
OZONE_TAB_TEXTURES_FILES[i], sizeof(filename));
strlcat(filename, FILE_PATH_PNG_EXTENSION, sizeof(filename));

View File

@ -1089,7 +1089,6 @@ static char* xmb_path_dynamic_wallpaper(xmb_handle_t *xmb)
char *tmp = string_replace_substring(xmb->title_name, "/", " ");
settings_t *settings = config_get_ptr();
const char *dir_dynamic_wallpapers = settings->paths.directory_dynamic_wallpapers;
path[0] = '\0';
if (tmp)
{
@ -2261,9 +2260,7 @@ static void xmb_context_reset_horizontal_list(
/* Add current node to playlist database name map */
RHMAP_SET_STR(xmb->playlist_db_node_map, path, node);
iconpath[0] = sysname[0] =
texturepath[0] = content_texturepath[0] = '\0';
iconpath[0] = '\0';
fill_pathname_base(sysname, path, sizeof(sysname));
path_remove_extension(sysname);
@ -2304,7 +2301,7 @@ static void xmb_context_reset_horizontal_list(
fill_pathname_join_delim(sysname, sysname,
FILE_PATH_CONTENT_BASENAME, '-',
sizeof(sysname));
strlcat(content_texturepath, iconpath, sizeof(content_texturepath));
strlcpy(content_texturepath, iconpath, sizeof(content_texturepath));
strlcat(content_texturepath, sysname, sizeof(content_texturepath));
/* If the content icon doesn't exist return default-content */
@ -3294,12 +3291,9 @@ static int xmb_draw_item(
if (entry_type == FILE_TYPE_CONTENTLIST_ENTRY)
{
char entry_path[PATH_MAX_LENGTH];
entry_path[0] = '\0';
strlcpy(entry_path, entry.path, sizeof(entry_path));
fill_pathname(entry_path, path_basename(entry_path), "",
sizeof(entry_path));
if (!string_is_empty(entry_path))
strlcpy(entry.path, entry_path, sizeof(entry.path));
}
@ -3933,7 +3927,7 @@ static void xmb_show_fullscreen_thumbnails(
* and all thumbnails for current selection are already
* loaded/available */
gfx_thumbnail_get_core_name(xmb->thumbnail_path_data, &core_name);
if (string_is_equal(core_name, "imageviewer") ||
if ( string_is_equal(core_name, "imageviewer") ||
!string_is_empty(xmb->savestate_thumbnail_file_path))
{
/* imageviewer content requires special treatment,
@ -4907,11 +4901,11 @@ static void xmb_draw_fullscreen_thumbnails(
{
char title_buf[255];
gfx_animation_ctx_ticker_smooth_t ticker_smooth;
int title_x = 0;
unsigned ticker_x_offset = 0;
unsigned ticker_str_width = 0;
int title_x = 0;
unsigned ticker_x_offset = 0;
unsigned ticker_str_width = 0;
title_buf[0] = '\0';
title_buf[0] = '\0';
ticker_smooth.idx = p_anim->ticker_pixel_idx;
ticker_smooth.font = xmb->font;

View File

@ -3761,7 +3761,6 @@ bool menu_shader_manager_save_preset_internal(
if ((type = menu_shader_manager_get_type(shader)) == RARCH_SHADER_NONE)
return false;
buffer[0] = '\0';
preset_ext = video_shader_get_preset_extension(type);
if (!string_is_empty(basename))

View File

@ -457,13 +457,9 @@ static bool menu_screensaver_update_state(
!screensaver->font_data.font &&
screensaver->font_enabled)
{
#if defined(HAVE_FREETYPE) || (defined(__APPLE__) && defined(HAVE_CORETEXT)) || defined(HAVE_STB_FONT)
char font_file[PATH_MAX_LENGTH];
#if defined(HAVE_FREETYPE) || (defined(__APPLE__) && defined(HAVE_CORETEXT)) || defined(HAVE_STB_FONT)
char pkg_path[PATH_MAX_LENGTH];
font_file[0] = '\0';
pkg_path[0] = '\0';
/* Get font file path */
if (!string_is_empty(dir_assets))
fill_pathname_join(pkg_path, dir_assets, MENU_SS_PKG_DIR, sizeof(pkg_path));
@ -483,7 +479,6 @@ static bool menu_screensaver_update_state(
/* On platforms without TTF support, there is
* no need to generate a font path (a bitmap
* font will be created automatically) */
char font_file[PATH_MAX_LENGTH];
font_file[0] = '\0';
#endif