[libunwind] [libunwind] Remove unnecessary dependencies on fprintf and stdio.h for increased baremetal friendliness (PR #72040)

Alexander Richardson via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 20 10:44:32 PST 2023


================
@@ -672,7 +671,7 @@ inline bool LocalAddressSpace::findFunctionName(pint_t addr, char *buf,
   Dl_info dyldInfo;
   if (dladdr((void *)addr, &dyldInfo)) {
     if (dyldInfo.dli_sname != NULL) {
-      snprintf(buf, bufLen, "%s", dyldInfo.dli_sname);
+      strncpy(buf, dyldInfo.dli_sname, bufLen);
----------------
arichardson wrote:

This will always write up to 512 '\0' bytes. maybe best to use memcpy+strlen instead? 

https://github.com/llvm/llvm-project/pull/72040


More information about the cfe-commits mailing list