Off-by-one error in uses_rfcomm

Variable len could be assigned to PATH_MAX + 1 length (returned
 from readlink) and this variable is used as index to array link
of size only PATH_MAX + 1.
This commit is contained in:
Pavel Raiskup 2011-08-16 11:46:44 +02:00 committed by Johan Hedberg
parent 7af9f8687e
commit b52dc7e907

View File

@ -104,7 +104,7 @@ static int uses_rfcomm(char *path, char *dev)
while ((de = readdir(dir)) != NULL) {
char link[PATH_MAX + 1];
int len = readlink(de->d_name, link, sizeof(link));
int len = readlink(de->d_name, link, PATH_MAX);
if (len > 0) {
link[len] = 0;
if (strstr(link, dev)) {