Skip to contentSkip to conversation

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

PATCH In review Barry Song 2 participants 2 messages May 25, 2010

Subsystems (3)
lore
Share & tools
lore

Barry Song

author
#0 lore raw

PATCH v3 1/1 iio-utils: fix memory overflow for dynamically allocateded memory to hold filename

---
 drivers/staging/iio/Documentation/iio_utils.h |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/staging/iio/Documentation/iio_utils.h +1 -2
index a4555e6..014f668 100644
@@ -62,9 +62,8 @@ inline int find_type_by_name(const char *name, const char *type)
 					1) != 0) {
 				filename = malloc(strlen(iio_dir)
 						+ strlen(type)
-						+ 1
 						+ numstrlen
-						+ 1);
+						+ 6);
 				if (filename == NULL)
 					return -ENOMEM;
 				sprintf(filename, "%s%s%d/name",
Signature · 1 line
1.5.6.3
Acked-by on v3 1/1
#1 lore raw
Quoted 1 line · Barry Song

Thanks Barry!

Quoted 19 lines
---
 drivers/staging/iio/Documentation/iio_utils.h |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/staging/iio/Documentation/iio_utils.h +1 -2
index a4555e6..014f668 100644
@@ -62,9 +62,8 @@ inline int find_type_by_name(const char *name, const char *type)
 					1) != 0) {
 				filename = malloc(strlen(iio_dir)
 						+ strlen(type)
-						+ 1
 						+ numstrlen
-						+ 1);
+						+ 6);
 				if (filename == NULL)
 					return -ENOMEM;
 				sprintf(filename, "%s%s%d/name",