media-ctl: Fix off-by-one buffer overflow with readlink
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Tue, 3 Jun 2014 09:53:23 +0000 (11:53 +0200)
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Tue, 3 Jun 2014 09:57:00 +0000 (11:57 +0200)
commit8b0636338b187262811407cfb44cf24e76f2ffaf
treef85012f66997be6fae11fff42263dbd4e48450e3
parent341f2f04a552b3b436a957e95d8af250c2cd1afb
media-ctl: Fix off-by-one buffer overflow with readlink

readlink() returns the number of bytes written to the buffer, which can
be up to the passed buffer size, without including the terminating '\0'.
This causes an off-by-one overflow as we pass the total buffer length to
the function and then try to append a terminating '\0'.

Fix it by passing the buffer size minus one to readlink().

Reported-by: Coverity Scan
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
utils/media-ctl/libmediactl.c