Staging: iio-utils: fix memory overflow for dynamically allocateded memory to hold...
authorBarry Song <21cnbao@gmail.com>
Tue, 25 May 2010 09:40:04 +0000 (17:40 +0800)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 4 Jun 2010 20:38:57 +0000 (13:38 -0700)
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>
drivers/staging/iio/Documentation/iio_utils.h

index a4555e6f133f0f4cca98924a6085aa8b7f0b6ad0..014f6684faba94f8ba6c28fcd606a131050bfdde 100644 (file)
@@ -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",