From 6733843f87aa3b1ad3dfe1ae76f0c76329617909 Mon Sep 17 00:00:00 2001 From: Allen Bai Date: Wed, 5 Jun 2019 10:30:31 -0400 Subject: [PATCH] lib/util: Fix segfault when validating filename This change fixes the segfault issue when calling ostree_repo_checkout_tree with empty GFileInfo. A simple condition check for NULL value is added at src/libotutil/ot-unix-utils.c:46. Closes: ostreedev#1864. Closes: #1868 Approved by: jlebon --- src/libotutil/ot-unix-utils.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libotutil/ot-unix-utils.c b/src/libotutil/ot-unix-utils.c index 7778ca11..17016ae1 100644 --- a/src/libotutil/ot-unix-utils.c +++ b/src/libotutil/ot-unix-utils.c @@ -43,6 +43,8 @@ gboolean ot_util_filename_validate (const char *name, GError **error) { + if (name == NULL) + return glnx_throw (error, "Invalid NULL filename"); if (strcmp (name, ".") == 0) return glnx_throw (error, "Invalid self-referential filename '.'"); if (strcmp (name, "..") == 0)