diff options
author | Paul Taysom <taysom@chromium.org> | 2013-07-12 13:03:57 -0700 |
---|---|---|
committer | ChromeBot <chrome-bot@google.com> | 2013-07-12 15:52:31 -0700 |
commit | d4c5b8be615a84dae6ced41747246d7a038b7b88 (patch) | |
tree | f2db697b6a8ad8ed1edae077ad556cbee81b07f8 | |
parent | c9880282b115a0127c948d16f4ab3c6cadcbfcd2 (diff) | |
download | platform_external_rootdev-d4c5b8be615a84dae6ced41747246d7a038b7b88.tar.gz platform_external_rootdev-d4c5b8be615a84dae6ced41747246d7a038b7b88.tar.bz2 platform_external_rootdev-d4c5b8be615a84dae6ced41747246d7a038b7b88.zip |
Fixed reference to overlapping (the same) string.
The intent of the rootdev_get_device_slave is to allow the slave and
the device to be the same string but it is not required. Added a
test for the case where they are the same string to not do the
strncpy.
Linux has vixed the problem of a limited number of stacked devices,
so I fixed the comment that referred to it.
BUG=chromium:259893
TEST=rootdev -s
Change-Id: I04d84799e77c678f1330e1bcf72cddaf9ac68c4c
Reviewed-on: https://gerrit.chromium.org/gerrit/61707
Tested-by: Paul Taysom <taysom@chromium.org>
Reviewed-by: Yunlian Jiang <yunlian@chromium.org>
Commit-Queue: Paul Taysom <taysom@chromium.org>
-rw-r--r-- | rootdev.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -22,9 +22,9 @@ #include <unistd.h> /* - * A depth of more than about 4 slave devices - * will run out of kernel stack space, so setting - * the serach depth to 8 covers all possible cases. + * Limit prevents endless looping to find slave. + * We currently have at most 2 levels, this allows + * for future growth. */ #define MAX_SLAVE_DEPTH 8 @@ -283,7 +283,8 @@ void rootdev_get_device_slave(char *slave, size_t size, dev_t *dev, * and find the last device. For example, verity can be stacked on bootcache * that is stacked on a disk partition. */ - strncpy(slave, device, size); + if (slave != device) + strncpy(slave, device, size); slave[size - 1] = '\0'; for (i = 0; i < MAX_SLAVE_DEPTH; i++) { len = snprintf(dst, sizeof(dst), "%s/%s/slaves", search, slave); |