sheepdog: Don't truncate long VDI name in _open(), _create()

sd_parse_uri() truncates long VDI names silently.  Reject them
instead.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
Markus Armbruster 2017-03-06 20:00:40 +01:00 committed by Kevin Wolf
parent 89e2a31d33
commit daa0b0d4b1

View file

@ -985,7 +985,10 @@ static int sd_parse_uri(BDRVSheepdogState *s, const char *filename,
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
} }
pstrcpy(vdi, SD_MAX_VDI_LEN, uri->path + 1); if (g_strlcpy(vdi, uri->path + 1, SD_MAX_VDI_LEN) >= SD_MAX_VDI_LEN) {
ret = -EINVAL;
goto out;
}
qp = query_params_parse(uri->query); qp = query_params_parse(uri->query);
if (qp->n > 1 || (s->is_unix && !qp->n) || (!s->is_unix && qp->n)) { if (qp->n > 1 || (s->is_unix && !qp->n) || (!s->is_unix && qp->n)) {