From 6e1bbbab0877edf64fdd989c89f5012e0e6f00bb Mon Sep 17 00:00:00 2001 From: Rolf Neugebauer Date: Wed, 10 Aug 2016 10:34:18 +0100 Subject: [PATCH] hvtools: remove broken size check for mount points Signed-off-by: Rolf Neugebauer --- alpine/packages/hvtools/src/hv_kvp_daemon.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/alpine/packages/hvtools/src/hv_kvp_daemon.c b/alpine/packages/hvtools/src/hv_kvp_daemon.c index f07d88788..2ec9aca30 100644 --- a/alpine/packages/hvtools/src/hv_kvp_daemon.c +++ b/alpine/packages/hvtools/src/hv_kvp_daemon.c @@ -397,9 +397,9 @@ static int kvp_cifs_mount(const char *value) gw[strlen(gw) - 1] = '\0'; - /* Parse the value */ - - /* Make sure we have the right number of '\n' */ + /* Parse the value: + * Make sure we have the right number of '\n'. Makes the code + * below simpler: no check for strchr() return value required. */ for (i = 0, count = 0; value[i]; i++) count += (value[i] == '\n'); if (count != 4) { @@ -410,22 +410,12 @@ static int kvp_cifs_mount(const char *value) (void)strncpy(val, value, sizeof(val)); mntpoint = val; t = strchr(mntpoint, '\n'); - if ((unsigned int)(t - mntpoint) >= sizeof(mntpoint) - 1) { - syslog(LOG_ERR, "mount: Mount point too long"); - return -1; - } *t = '\0'; bindpoint = t + 1; t = strchr(bindpoint, '\n'); - if ((unsigned int)(t - bindpoint) >= sizeof(bindpoint) - 1) { - syslog(LOG_ERR, "mount: Bind mount point too long"); - return -1; - } *t = '\0'; - /* No need to check for length here as we check above for the - * right number of new-lines */ username = t + 1; t = strchr(username, '\n'); *t = '\0';