From: Tobias Stoeckmann <tobias@stoeckmann.org>
To: dri-devel@lists.freedesktop.org
Subject: [PATCH] nul-terminate readlink result
Date: Sat, 11 Jul 2015 11:02:57 +0200 [thread overview]
Message-ID: <20150711090257.GA13400@localhost> (raw)
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
next reply other threads:[~2015-07-11 11:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-11 9:02 Tobias Stoeckmann [this message]
2015-07-12 10:14 ` [PATCH] nul-terminate readlink result Tobias Stoeckmann
2015-07-13 15:42 ` Emil Velikov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150711090257.GA13400@localhost \
--to=tobias@stoeckmann.org \
--cc=dri-devel@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.