aboutsummaryrefslogtreecommitdiffstats
path: root/toolbox/mount.c
diff options
context:
space:
mode:
authorNick Kralevich <nnk@google.com>2013-04-24 16:31:02 -0700
committerChirayu Desai <cdesai@cyanogenmod.org>2013-05-01 14:46:54 +0530
commitbb8d238672af41d87b397327775b971391cbc9f5 (patch)
tree6ad9d352cc04384abc10f9b11387b3dc1c94ddd0 /toolbox/mount.c
parentc7fdf81b6a4a9c45e4d7179304b3e6578c746462 (diff)
downloadsystem_core-bb8d238672af41d87b397327775b971391cbc9f5.tar.gz
system_core-bb8d238672af41d87b397327775b971391cbc9f5.tar.bz2
system_core-bb8d238672af41d87b397327775b971391cbc9f5.zip
mount: fix incorrect string length calculation
Fix bug https://code.google.com/p/android/issues/detail?id=54192 which incorrectly calculated the length of a string. Fix compiler warning: system/core/toolbox/mount.c:59:2: warning: initializer-string for array of chars is too long [enabled by default] system/core/toolbox/mount.c:59:2: warning: (near initialization for 'options[16].str') [enabled by default] Change-Id: If8663f8311c6348a730fcf731d402b57fee10cb5
Diffstat (limited to 'toolbox/mount.c')
-rw-r--r--toolbox/mount.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/toolbox/mount.c b/toolbox/mount.c
index b7adce2d..bcda2a28 100644
--- a/toolbox/mount.c
+++ b/toolbox/mount.c
@@ -19,7 +19,7 @@
#define LOOPDEV_MAXLEN 64
struct mount_opts {
- const char str[8];
+ const char str[16];
unsigned long rwmask;
unsigned long rwset;
unsigned long rwnoset;
@@ -65,10 +65,11 @@ static const struct mount_opts options[] = {
static void add_extra_option(struct extra_opts *extra, char *s)
{
int len = strlen(s);
- int newlen = extra->used_size + len;
+ int newlen;
if (extra->str)
len++; /* +1 for ',' */
+ newlen = extra->used_size + len;
if (newlen >= extra->alloc_size) {
char *new;
@@ -79,7 +80,7 @@ static void add_extra_option(struct extra_opts *extra, char *s)
extra->str = new;
extra->end = extra->str + extra->used_size;
- extra->alloc_size = newlen;
+ extra->alloc_size = newlen + 1;
}
if (extra->used_size) {