virStream: Forbid negative seeks

Currently, we don't assign any meaning to that. Our current view
on virStream is that it's merely a pipe. And pipes don't support
seeking.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Michal Privoznik 2017-05-18 08:27:27 +02:00
parent 445a340bd4
commit 0da4a635bc
3 changed files with 9 additions and 0 deletions

View File

@ -527,6 +527,13 @@
goto label; \
} \
} while (0)
# define virCheckPositiveArgReturn(argname, retval) \
do { \
if (argname <= 0) { \
virReportInvalidPositiveArg(argname); \
return retval; \
} \
} while (0)
# define virCheckNonZeroArgGoto(argname, label) \
do { \
if (argname == 0) { \

View File

@ -367,6 +367,7 @@ virNetClientStreamSetHole(virNetClientStreamPtr st,
unsigned int flags)
{
virCheckFlags(0, -1);
virCheckPositiveArgReturn(length, -1);
/* Shouldn't happen, But it's better to safe than sorry. */
if (st->holeLength) {

View File

@ -950,6 +950,7 @@ virFDStreamSendHole(virStreamPtr st,
int ret = -1;
virCheckFlags(0, -1);
virCheckPositiveArgReturn(length, -1);
virObjectLock(fdst);
if (fdst->length) {