All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nul-terminate readlink result
@ 2015-07-11  9:02 Tobias Stoeckmann
  2015-07-12 10:14 ` Tobias Stoeckmann
  0 siblings, 1 reply; 3+ messages in thread
From: Tobias Stoeckmann @ 2015-07-11  9:02 UTC (permalink / raw)
  To: dri-devel

readlink by itself does not guarantee that its result is properly
nul-terminated. Setting the last byte of the buffer to '\0' fixes
this issue.
---
 libkms/linux.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libkms/linux.c b/libkms/linux.c
index 4d47148..667d37c 100644
--- a/libkms/linux.c
+++ b/libkms/linux.c
@@ -82,6 +82,7 @@ linux_name_from_sysfs(int fd, char **out)
 
 	if (readlink(path, link, PATH_SIZE) < 0)
 		return -EINVAL;
+	link[PATH_SIZE] = '\0';
 
 	/* link looks something like this: ../../../bus/pci/drivers/intel */
 	slash_name = strrchr(link, '/');
-- 
2.4.5

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-07-13 15:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-11  9:02 [PATCH] nul-terminate readlink result Tobias Stoeckmann
2015-07-12 10:14 ` Tobias Stoeckmann
2015-07-13 15:42   ` Emil Velikov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.