summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2017-11-07 15:06:46 +0100
committerLeah Neukirchen <leah@vuxu.org>2017-11-07 15:06:46 +0100
commitc219bd79099b10529c6561e5130b2ef1c3b86cb2 (patch)
treef50ab390e1f257f56ce330d072aa821fac30d1da
parent5c972c5e9d79781e42bbdd7f7ff05a9830d94b23 (diff)
downloadlr-c219bd79099b10529c6561e5130b2ef1c3b86cb2.tar.gz
lr-c219bd79099b10529c6561e5130b2ef1c3b86cb2.tar.xz
lr-c219bd79099b10529c6561e5130b2ef1c3b86cb2.zip
readlin: check if buffer is too small
-rw-r--r--lr.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lr.c b/lr.c
index 4d897b8..23dd6b6 100644
--- a/lr.c
+++ b/lr.c
@@ -897,8 +897,8 @@ static const char *
 readlin(const char *p, const char *alt)
 {
 	static char b[PATH_MAX];
-	int r = readlink(p, b, sizeof b - 1);
-	if (r < 0)
+	ssize_t r = readlink(p, b, sizeof b - 1);
+	if (r < 0 || (size_t)r >= sizeof b - 1)
 		return alt;
 	b[r] = 0;
 	return b;