Skip to contentSkip to conversation

system/qtest: Fix length parameter in the b64write code

PATCH In review Thomas Huth 3 participants 3 messages May 18

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 system/qtest: Fix length parameter in the b64write code

From: Thomas Huth <[email protected]>

The b64write code has a sanity check that the given lengths matches the real length of the given data, and calculates the minimum of the two values to be on the safe side. However, the address_space_write() then uses the original value and ignores the calculated minimum. Use out_len here to fix the problem.

Fixes 70da30483e7 ("qtest: Use cpu address space instead of system memory")
---
 system/qtest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
system/qtest.c +1 -1
index a79d10d1361..d6db057b0a2 100644
@@ -698,7 +698,7 @@ static void qtest_process_command(CharFrontend *chr, gchar **words)
         }
 
         address_space_write(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, data,
-                            len);
+                            out_len);
 
         qtest_send(chr, "OK\n");
     } else if (strcmp(words[0], "endianness") == 0) {
Signature · 1 line
2.54.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 19 lines · Thomas Huth

From: Thomas Huth <[email protected]>

The b64write code has a sanity check that the given lengths matches the real length of the given data, and calculates the minimum of the two values to be on the safe side. However, the address_space_write() then uses the original value and ignores the calculated minimum. Use out_len here to fix the problem.

Fixes 70da30483e7 ("qtest: Use cpu address space instead of system memory")
---
  system/qtest.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
system/qtest.c +0 -0
index a79d10d1361..d6db057b0a2 100644

system/qtest.c static void qtest_process_command(CharFrontend *chr, gchar **words) · line 704

Quoted 8 lines
system/qtest.c +1 -1
@@ -698,7 +698,7 @@ static void qtest_process_command(CharFrontend *chr, gchar **words)
          }
 
          address_space_write(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, data,
-                            len);
+                            out_len);
 
          qtest_send(chr, "OK\n");
      } else if (strcmp(words[0], "endianness") == 0) {
Reviewed-by on v1 1/1
#2 lore raw
In reply to Thomas Huth
Quoted 8 lines · Thomas Huth

From: Thomas Huth <[email protected]>

The b64write code has a sanity check that the given lengths matches the real length of the given data, and calculates the minimum of the two values to be on the safe side. However, the address_space_write() then uses the original value and ignores the calculated minimum. Use out_len here to fix the problem.

Quoted 5 lines
Fixes 70da30483e7 ("qtest: Use cpu address space instead of system memory")
---
  system/qtest.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)