[PATCH 2/2] virStream: Forbid negative seeks

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

 



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@xxxxxxxxxx>
---
 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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux