From 687767bd8f4f471c2c6e9509125a78d7cb5f0f62 Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Tue, 15 Nov 2022 00:29:35 -0500 Subject: convert a few more strlcpy to strmemccpy calls Fix Red and Yellow albumart is imported to plugins just use a macro substitution for now Change-Id: I7c2e10d7559c087f0b3d0e6b844027d3b323da55 --- apps/iap/iap-lingo4.c | 2 +- apps/onplay.c | 6 +++--- apps/playlist.c | 2 +- apps/recorder/albumart.c | 6 ++++++ apps/tree.c | 4 ++-- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/apps/iap/iap-lingo4.c b/apps/iap/iap-lingo4.c index 77ddeabcb3..eb629407f2 100644 --- a/apps/iap/iap-lingo4.c +++ b/apps/iap/iap-lingo4.c @@ -24,6 +24,7 @@ #include "filetree.h" #include "wps.h" #include "playback.h" +#include "string-extra.h" /* * This macro is meant to be used inside an IAP mode message handler. @@ -1430,7 +1431,6 @@ void iap_handlepkt_mode4(const unsigned int len, const unsigned char *buf) unsigned int number_of_playlists = nbr_total_playlists(); uint32_t trackcount; trackcount = playlist_amount(); - size_t len; if ((buf[3] == 0x05) && ((start_index + read_count ) > trackcount)) { diff --git a/apps/onplay.c b/apps/onplay.c index 8d53e26fc5..8507699bd3 100644 --- a/apps/onplay.c +++ b/apps/onplay.c @@ -126,8 +126,8 @@ static bool clipboard_clip(struct clipboard *clip, const char *path, unsigned int attr, unsigned int flags) { /* if it fits it clips */ - if (strlcpy(clip->path, path, sizeof (clip->path)) - < sizeof (clip->path)) { + if (strmemccpy(clip->path, path, sizeof (clip->path)) != NULL) + { clip->attr = attr; clip->flags = flags; return true; @@ -1048,7 +1048,7 @@ static int rename_file(void) size_t pathlen = oldbase - selection; char *newbase = newname + pathlen; - if (strlcpy(newname, selection, sizeof (newname)) >= sizeof (newname)) { + if (strmemccpy(newname, selection, sizeof (newname)) == NULL) { /* Too long */ } else if (kbd_input(newbase, sizeof (newname) - pathlen, NULL) < 0) { rc = OPRC_CANCELLED; diff --git a/apps/playlist.c b/apps/playlist.c index ab5c59328a..b721a82093 100644 --- a/apps/playlist.c +++ b/apps/playlist.c @@ -1400,7 +1400,7 @@ static int get_filename(struct playlist_info* playlist, int index, int seek, if (playlist->in_ram && !control_file && max < 0) { - max = strlcpy(tmp_buf, (char*)&playlist->buffer[seek], sizeof(tmp_buf)); + strmemccpy(tmp_buf, (char*)&playlist->buffer[seek], sizeof(tmp_buf)); } else if (max < 0) { diff --git a/apps/recorder/albumart.c b/apps/recorder/albumart.c index 8991a81848..c0d9e6d86f 100644 --- a/apps/recorder/albumart.c +++ b/apps/recorder/albumart.c @@ -39,6 +39,12 @@ #define USE_JPEG_COVER #endif +#ifdef PLUGIN + #define strmemccpy strlcpy + /* Note we don't use the return value so this works */ + /* FIXME if strmemccpy gets added to the rb->plugin struct */ +#endif + /* Strip filename from a full path * * buf - buffer to extract directory to. diff --git a/apps/tree.c b/apps/tree.c index 23a909281d..e8655cd0d0 100644 --- a/apps/tree.c +++ b/apps/tree.c @@ -511,10 +511,10 @@ char *getcwd(char *buf, getcwd_size_t size) return tc.currdir; else if (size) { - if ((getcwd_size_t)strlcpy(buf, tc.currdir, size) < size) + if (strmemccpy(buf, tc.currdir, size) != NULL) return buf; } - /* size == 0, or truncation in strlcpy */ + /* size == 0, or truncation in strmemccpy */ return NULL; } -- cgit v1.2.3