[ostree] core: Preemptively error out on paths longer than PATH_MAX



commit 786ce3b560eca0dee7b632c120210b8e4a9c4e7b
Author: Colin Walters <walters verbum org>
Date:   Thu Dec 22 16:50:01 2011 -0500

    core: Preemptively error out on paths longer than PATH_MAX
    
    Just noticed this while thinking like an attacker.

 src/libotutil/ot-unix-utils.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
---
diff --git a/src/libotutil/ot-unix-utils.c b/src/libotutil/ot-unix-utils.c
index e7357d7..f07facb 100644
--- a/src/libotutil/ot-unix-utils.c
+++ b/src/libotutil/ot-unix-utils.c
@@ -132,6 +132,13 @@ ot_util_path_split_validate (const char *path,
   GPtrArray *ret_components = NULL;
   int i;
 
+  if (strlen (path) > PATH_MAX)
+    {
+      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+                   "Path '%s' is too long", path);
+      goto out;
+    }
+
   ret_components = ot_split_string_ptrarray (path, '/');
 
   /* Canonicalize by removing '.' and '', throw an error on .. */



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