[PATCH 4/5] qemu-file: qemu_file_get_fd(): check service byte itself

Vladimir Sementsov-Ogievskiy posted 5 patches 3 weeks, 5 days ago
Maintainers: Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>
[PATCH 4/5] qemu-file: qemu_file_get_fd(): check service byte itself
Posted by Vladimir Sementsov-Ogievskiy 3 weeks, 5 days ago
We can check it, so, why not.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
---
 migration/qemu-file.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/migration/qemu-file.c b/migration/qemu-file.c
index 3a9a0a49d4..da701d40e4 100644
--- a/migration/qemu-file.c
+++ b/migration/qemu-file.c
@@ -390,13 +390,19 @@ int qemu_file_get_fd(QEMUFile *f)
     int fd = -1;
     FdEntry *fde;
     Error *err = NULL;
+    int service_byte;
 
     if (!f->can_pass_fd) {
         error_setg(&err, "%s does not support fd passing", f->ioc->name);
         goto fail;
     }
 
-    qemu_get_byte(f);
+    service_byte = qemu_get_byte(f);
+    if (service_byte != ' ') {
+        error_setg(&err, "%s unexpected service byte: %d(%c)", f->ioc->name,
+                   service_byte, service_byte);
+        goto fail;
+    }
 
     fde = QTAILQ_FIRST(&f->fds);
     if (!fde) {
-- 
2.48.1
Re: [PATCH 4/5] qemu-file: qemu_file_get_fd(): check service byte itself
Posted by Fabiano Rosas 3 weeks, 5 days ago
Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> writes:

> We can check it, so, why not.
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
> ---
>  migration/qemu-file.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/migration/qemu-file.c b/migration/qemu-file.c
> index 3a9a0a49d4..da701d40e4 100644
> --- a/migration/qemu-file.c
> +++ b/migration/qemu-file.c
> @@ -390,13 +390,19 @@ int qemu_file_get_fd(QEMUFile *f)
>      int fd = -1;
>      FdEntry *fde;
>      Error *err = NULL;
> +    int service_byte;
>  
>      if (!f->can_pass_fd) {
>          error_setg(&err, "%s does not support fd passing", f->ioc->name);
>          goto fail;
>      }
>  
> -    qemu_get_byte(f);
> +    service_byte = qemu_get_byte(f);
> +    if (service_byte != ' ') {
> +        error_setg(&err, "%s unexpected service byte: %d(%c)", f->ioc->name,
> +                   service_byte, service_byte);
> +        goto fail;
> +    }
>  
>      fde = QTAILQ_FIRST(&f->fds);
>      if (!fde) {

Reviewed-by: Fabiano Rosas <farosas@suse.de>