From 687cae783e032eb38b236de627931d3c343aeb4f Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 13 Sep 2016 13:13:43 -0400 Subject: [PATCH] Always set an error when failing name validation This was an oversight in the previous patch to improve name validation error messages. --- common/flatpak-utils.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/common/flatpak-utils.c b/common/flatpak-utils.c index c589661d5..42eced13c 100644 --- a/common/flatpak-utils.c +++ b/common/flatpak-utils.c @@ -416,8 +416,19 @@ flatpak_is_valid_name (const char *string, ret = FALSE; len = strlen (string); - if (G_UNLIKELY (len == 0 || len > 255)) - goto out; + if (G_UNLIKELY (len == 0)) + { + g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, + "Name can't be empty"); + goto out; + } + + if (G_UNLIKELY (len > 255)) + { + g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, + "Name can't be longer than 255 characters"); + goto out; + } end = string + len;