diff options
| author | Darrick J. Wong <darrick.wong@oracle.com> | 2013-12-12 13:12:09 -0500 |
|---|---|---|
| committer | Theodore Ts'o <tytso@mit.edu> | 2013-12-12 13:12:11 -0500 |
| commit | e46c187aa6ee1ad6f38f0fb9c39da5e2bb6ceeb9 (patch) | |
| tree | 9d23dba4df93e0481ac8d1e12ab08638ff4f360f /lib/ss | |
| parent | dc9da630d6f3d6c7284df97f5015e32329da3307 (diff) | |
| download | android_external_e2fsprogs-e46c187aa6ee1ad6f38f0fb9c39da5e2bb6ceeb9.tar.gz android_external_e2fsprogs-e46c187aa6ee1ad6f38f0fb9c39da5e2bb6ceeb9.tar.bz2 android_external_e2fsprogs-e46c187aa6ee1ad6f38f0fb9c39da5e2bb6ceeb9.zip | |
libss: fix memory handling errors
Fix memory allocation calculations and check for NULL pointer returns.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'lib/ss')
| -rw-r--r-- | lib/ss/invocation.c | 5 | ||||
| -rw-r--r-- | lib/ss/parse.c | 4 | ||||
| -rw-r--r-- | lib/ss/request_tbl.c | 2 |
3 files changed, 10 insertions, 1 deletions
diff --git a/lib/ss/invocation.c b/lib/ss/invocation.c index a7110500..08b66f28 100644 --- a/lib/ss/invocation.c +++ b/lib/ss/invocation.c @@ -20,6 +20,7 @@ #ifdef HAVE_DLOPEN #include <dlfcn.h> #endif +#include <errno.h> int ss_create_invocation(subsystem_name, version_string, info_ptr, request_table_ptr, code_ptr) @@ -46,6 +47,10 @@ int ss_create_invocation(subsystem_name, version_string, info_ptr, ; table = (ss_data **) realloc((char *)table, ((unsigned)sci_idx+2)*size); + if (table == NULL) { + *code_ptr = errno; + return 0; + } table[sci_idx+1] = (ss_data *) NULL; table[sci_idx] = new_table; diff --git a/lib/ss/parse.c b/lib/ss/parse.c index b70ad165..baded665 100644 --- a/lib/ss/parse.c +++ b/lib/ss/parse.c @@ -90,6 +90,10 @@ char **ss_parse (sci_idx, line_ptr, argc_ptr) parse_mode = TOKEN; cp = line_ptr; argv = NEW_ARGV (argv, argc); + if (argv == NULL) { + *argc_ptr = errno; + return argv; + } argv[argc++] = line_ptr; argv[argc] = NULL; } diff --git a/lib/ss/request_tbl.c b/lib/ss/request_tbl.c index b0b6f959..efdabfa3 100644 --- a/lib/ss/request_tbl.c +++ b/lib/ss/request_tbl.c @@ -35,7 +35,7 @@ void ss_add_request_table(sci_idx, rqtbl_ptr, position, code_ptr) ; /* size == C subscript of NULL == #elements */ size += 2; /* new element, and NULL */ - t = (ssrt **)realloc(info->rqt_tables, (unsigned)size*sizeof(ssrt)); + t = (ssrt **)realloc(info->rqt_tables, (unsigned)size*sizeof(ssrt *)); if (t == (ssrt **)NULL) { *code_ptr = errno; return; |
