From 582b81d08f0ba70612aa173dae5f31263295826f Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Fri, 4 Dec 2015 13:51:28 +0100 Subject: [PATCH 1/2] SYSDB: Treat empty elements as not found in sysdb_attrs_get_string() --- src/db/sysdb.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/db/sysdb.c b/src/db/sysdb.c index a71364d7c4b600eafd10fafa6641eac7b2292764..97a7c52bb49dc072d371ffb657540d2ed2f3d0b7 100644 --- a/src/db/sysdb.c +++ b/src/db/sysdb.c @@ -371,7 +371,13 @@ int sysdb_attrs_get_string(struct sysdb_attrs *attrs, const char *name, return ret; } - if (el->num_values != 1) { + /* There is no guarantee that the element wasn't added before + * with sysdb_attrs_get_el() as empty, we should treat empty + * elements as not found + */ + if (el->num_values == 0) { + return ENOENT; + } else if (el->num_values != 1) { return ERANGE; } -- 2.4.3