diff --git a/source/blender/blenlib/BLI_string.h b/source/blender/blenlib/BLI_string.h index 770a4c0e3ab..c6f0bc49c9b 100644 --- a/source/blender/blenlib/BLI_string.h +++ b/source/blender/blenlib/BLI_string.h @@ -72,6 +72,13 @@ __attribute__((nonnull)) #endif ; +size_t BLI_strcpy_rlen(char *__restrict dst, const char *__restrict src) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; + char *BLI_str_quoted_substrN(const char *__restrict str, const char *__restrict prefix) #ifdef __GNUC__ __attribute__((warn_unused_result)) diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c index aba73936975..9d811aba503 100644 --- a/source/blender/blenlib/intern/string.c +++ b/source/blender/blenlib/intern/string.c @@ -139,6 +139,13 @@ size_t BLI_strncpy_rlen(char *__restrict dst, const char *__restrict src, const return srclen; } +size_t BLI_strcpy_rlen(char *__restrict dst, const char *__restrict src) +{ + size_t srclen = strlen(src); + memcpy(dst, src, srclen + 1); + return srclen; +} + /** * Portable replacement for #vsnprintf */ diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index cb0784397ef..5a1ba8f31f0 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -2371,13 +2371,13 @@ void ui_check_but(uiBut *but) char *str = but->drawstr; if (but->modifier_key & KM_SHIFT) - str = strcat(str, "Shift "); + str += BLI_strcpy_rlen(str, "Shift "); if (but->modifier_key & KM_CTRL) - str = strcat(str, "Ctrl "); + str += BLI_strcpy_rlen(str, "Ctrl "); if (but->modifier_key & KM_ALT) - str = strcat(str, "Alt "); + str += BLI_strcpy_rlen(str, "Alt "); if (but->modifier_key & KM_OSKEY) - str = strcat(str, "Cmd "); + str += BLI_strcpy_rlen(str, "Cmd "); (void)str; /* UNUSED */ }