-
Notifications
You must be signed in to change notification settings - Fork 40
Closed
Description
while pointing valgrind at something unrelated it spotted the use of uninitialized memory in po_basename() in mylog.c. this is because GetExeProgramName() calls readlink(), readlink() doesn't add a terminating null and GetExeProgramName() doesn't add one itself, so the strrchr() in po_basename() can then start from garbage.
this fixes it:
diff --git a/mylog.c b/mylog.c
index 9377ad2..66e24a9 100644
--- a/mylog.c
+++ b/mylog.c
@@ -133,8 +133,10 @@ const char *GetExeProgramName()
for (i = 0; i < sizeof(flist) / sizeof(flist[0]); i++)
{
- if (readlink(flist[i], path_name, sizeof(path_name)) > 0)
+ ssize_t len = readlink(flist[i], path_name, sizeof(path_name));
+ if (len > 0)
{
+ path_name[len] = 0;
/* fprintf(stderr, "i=%d pathname=%s\n", i, path_name); */
STRCPY_FIXED(exename, po_basename(path_name));
break;
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels