[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 2/2] 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>
---
 src/internal.h               | 7 +++++++
 src/rpc/virnetclientstream.c | 1 +
 src/util/virfdstream.c       | 1 +
 3 files changed, 9 insertions(+)

diff --git a/src/internal.h b/src/internal.h
index 5a5a430a2..9e7ef553d 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -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) {                         \
diff --git a/src/rpc/virnetclientstream.c b/src/rpc/virnetclientstream.c
index 7b28d63db..a9bf271dc 100644
--- a/src/rpc/virnetclientstream.c
+++ b/src/rpc/virnetclientstream.c
@@ -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) {
diff --git a/src/util/virfdstream.c b/src/util/virfdstream.c
index 6870d8846..7ee58be13 100644
--- a/src/util/virfdstream.c
+++ b/src/util/virfdstream.c
@@ -950,6 +950,7 @@ virFDStreamSendHole(virStreamPtr st,
     int ret = -1;
 
     virCheckFlags(0, -1);
+    virCheckPositiveArgReturn(length, -1);
 
     virObjectLock(fdst);
     if (fdst->length) {
-- 
2.13.0


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]