[libvirt PATCH 2/4] virfile: Use VIR_MAX_FILE_LEN instead of INT_MAX to limit file size

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

 



The use of INT_MAX as maximum file length is problematic for reasons
discussed in the next commit.

Signed-off-by: Tim Wiederhake <twiederh@xxxxxxxxxx>
---
 tests/networkxml2firewalltest.c | 2 +-
 tests/testutils.c               | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/tests/networkxml2firewalltest.c b/tests/networkxml2firewalltest.c
index 91336a0c55..114e17fbbd 100644
--- a/tests/networkxml2firewalltest.c
+++ b/tests/networkxml2firewalltest.c
@@ -176,7 +176,7 @@ mymain(void)
 
     basefile = g_strdup_printf("%s/networkxml2firewalldata/base.args", abs_srcdir);
 
-    if (virFileReadAll(basefile, INT_MAX, &baseargs) < 0)
+    if (virFileReadAll(basefile, VIR_MAX_FILE_LEN, &baseargs) < 0)
         return EXIT_FAILURE;
 
     DO_TEST("nat-default");
diff --git a/tests/testutils.c b/tests/testutils.c
index 7d87e30a5c..c71e099bf1 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -313,7 +313,7 @@ virTestLoadFileJSON(const char *p, ...)
     if (!(path = virTestLoadFileGetPath(p, ap)))
         goto cleanup;
 
-    if (virFileReadAll(path, INT_MAX, &jsonstr) < 0)
+    if (virFileReadAll(path, VIR_MAX_FILE_LEN, &jsonstr) < 0)
         goto cleanup;
 
     if (!(ret = virJSONValueFromString(jsonstr)))
@@ -562,7 +562,8 @@ virTestCompareToFileFull(const char *actual,
         if (virTestLoadFile(filename, &filecontent) < 0 && !virTestGetRegenerate())
             return -1;
     } else {
-        if (virFileReadAll(filename, INT_MAX, &filecontent) < 0 && !virTestGetRegenerate())
+        if (virFileReadAll(filename, VIR_MAX_FILE_LEN, &filecontent) < 0 &&
+            !virTestGetRegenerate())
             return -1;
     }
 
-- 
2.31.1




[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