Staging: iio-utils: fix memory overflow for dynamically allocateded memory to hold filename

Signed-off-by: Barry Song <21cnbao@gmail.com>
Acked-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
Barry Song 2010-05-25 17:40:04 +08:00 коммит произвёл Greg Kroah-Hartman
Родитель c3dee74f52
Коммит b6ee30a27f
1 изменённых файлов: 1 добавлений и 2 удалений

Просмотреть файл

@ -62,9 +62,8 @@ inline int find_type_by_name(const char *name, const char *type)
1) != 0) { 1) != 0) {
filename = malloc(strlen(iio_dir) filename = malloc(strlen(iio_dir)
+ strlen(type) + strlen(type)
+ 1
+ numstrlen + numstrlen
+ 1); + 6);
if (filename == NULL) if (filename == NULL)
return -ENOMEM; return -ENOMEM;
sprintf(filename, "%s%s%d/name", sprintf(filename, "%s%s%d/name",