|
|
2fc102 |
From 6ab5595ec7360bd4cc4c0494a1e0afedda701961 Mon Sep 17 00:00:00 2001
|
|
|
2fc102 |
From: Pavel Reichl <preichl@redhat.com>
|
|
|
2fc102 |
Date: Sun, 26 Jan 2014 12:39:43 +0000
|
|
|
2fc102 |
Subject: [PATCH 80/80] utils: handling NULL params in sss_parse_name
|
|
|
2fc102 |
|
|
|
2fc102 |
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
|
|
|
2fc102 |
---
|
|
|
2fc102 |
src/util/usertools.c | 50 +++++++++++++++++++++++++++-----------------------
|
|
|
2fc102 |
src/util/util.h | 2 +-
|
|
|
2fc102 |
2 files changed, 28 insertions(+), 24 deletions(-)
|
|
|
2fc102 |
|
|
|
2fc102 |
diff --git a/src/util/usertools.c b/src/util/usertools.c
|
|
|
2fc102 |
index 9edae41e0f216f9f0d1660e473f3aa1bf7160b06..fab0a261e82b8c4d8071ced1dac99b8e3b987b00 100644
|
|
|
2fc102 |
--- a/src/util/usertools.c
|
|
|
2fc102 |
+++ b/src/util/usertools.c
|
|
|
2fc102 |
@@ -322,7 +322,7 @@ done:
|
|
|
2fc102 |
|
|
|
2fc102 |
int sss_parse_name(TALLOC_CTX *memctx,
|
|
|
2fc102 |
struct sss_names_ctx *snctx,
|
|
|
2fc102 |
- const char *orig, char **domain, char **name)
|
|
|
2fc102 |
+ const char *orig, char **_domain, char **_name)
|
|
|
2fc102 |
{
|
|
|
2fc102 |
pcre *re = snctx->re;
|
|
|
2fc102 |
const char *result;
|
|
|
2fc102 |
@@ -346,31 +346,35 @@ int sss_parse_name(TALLOC_CTX *memctx,
|
|
|
2fc102 |
|
|
|
2fc102 |
strnum = ret;
|
|
|
2fc102 |
|
|
|
2fc102 |
- result = NULL;
|
|
|
2fc102 |
- ret = pcre_get_named_substring(re, orig, ovec, strnum, "name", &result);
|
|
|
2fc102 |
- if (ret < 0 || !result) {
|
|
|
2fc102 |
- DEBUG(2, ("Name not found!\n"));
|
|
|
2fc102 |
- return EINVAL;
|
|
|
2fc102 |
+ if (_name != NULL) {
|
|
|
2fc102 |
+ result = NULL;
|
|
|
2fc102 |
+ ret = pcre_get_named_substring(re, orig, ovec, strnum, "name", &result);
|
|
|
2fc102 |
+ if (ret < 0 || !result) {
|
|
|
2fc102 |
+ DEBUG(2, ("Name not found!\n"));
|
|
|
2fc102 |
+ return EINVAL;
|
|
|
2fc102 |
+ }
|
|
|
2fc102 |
+ *_name = talloc_strdup(memctx, result);
|
|
|
2fc102 |
+ pcre_free_substring(result);
|
|
|
2fc102 |
+ if (!*_name) return ENOMEM;
|
|
|
2fc102 |
}
|
|
|
2fc102 |
- *name = talloc_strdup(memctx, result);
|
|
|
2fc102 |
- pcre_free_substring(result);
|
|
|
2fc102 |
- if (!*name) return ENOMEM;
|
|
|
2fc102 |
|
|
|
2fc102 |
-
|
|
|
2fc102 |
- result = NULL;
|
|
|
2fc102 |
- ret = pcre_get_named_substring(re, orig, ovec, strnum, "domain", &result);
|
|
|
2fc102 |
- if (ret < 0 || !result) {
|
|
|
2fc102 |
- DEBUG(4, ("Domain not provided!\n"));
|
|
|
2fc102 |
- *domain = NULL;
|
|
|
2fc102 |
- } else {
|
|
|
2fc102 |
- /* ignore "" string */
|
|
|
2fc102 |
- if (*result) {
|
|
|
2fc102 |
- *domain = talloc_strdup(memctx, result);
|
|
|
2fc102 |
- pcre_free_substring(result);
|
|
|
2fc102 |
- if (!*domain) return ENOMEM;
|
|
|
2fc102 |
+ if (_domain != NULL) {
|
|
|
2fc102 |
+ result = NULL;
|
|
|
2fc102 |
+ ret = pcre_get_named_substring(re, orig, ovec, strnum, "domain",
|
|
|
2fc102 |
+ &result);
|
|
|
2fc102 |
+ if (ret < 0 || !result) {
|
|
|
2fc102 |
+ DEBUG(4, ("Domain not provided!\n"));
|
|
|
2fc102 |
+ *_domain = NULL;
|
|
|
2fc102 |
} else {
|
|
|
2fc102 |
- pcre_free_substring(result);
|
|
|
2fc102 |
- *domain = NULL;
|
|
|
2fc102 |
+ /* ignore "" string */
|
|
|
2fc102 |
+ if (*result) {
|
|
|
2fc102 |
+ *_domain = talloc_strdup(memctx, result);
|
|
|
2fc102 |
+ pcre_free_substring(result);
|
|
|
2fc102 |
+ if (!*_domain) return ENOMEM;
|
|
|
2fc102 |
+ } else {
|
|
|
2fc102 |
+ pcre_free_substring(result);
|
|
|
2fc102 |
+ *_domain = NULL;
|
|
|
2fc102 |
+ }
|
|
|
2fc102 |
}
|
|
|
2fc102 |
}
|
|
|
2fc102 |
|
|
|
2fc102 |
diff --git a/src/util/util.h b/src/util/util.h
|
|
|
2fc102 |
index 3334476ab83a137d957765fe2c9afba4ad0d014c..7b185bcb4287a4afc5bf67b40164cf69b9beeb19 100644
|
|
|
2fc102 |
--- a/src/util/util.h
|
|
|
2fc102 |
+++ b/src/util/util.h
|
|
|
2fc102 |
@@ -349,7 +349,7 @@ int sss_names_init(TALLOC_CTX *mem_ctx,
|
|
|
2fc102 |
|
|
|
2fc102 |
int sss_parse_name(TALLOC_CTX *memctx,
|
|
|
2fc102 |
struct sss_names_ctx *snctx,
|
|
|
2fc102 |
- const char *orig, char **domain, char **name);
|
|
|
2fc102 |
+ const char *orig, char **_domain, char **_name);
|
|
|
2fc102 |
|
|
|
2fc102 |
char *
|
|
|
2fc102 |
sss_get_cased_name(TALLOC_CTX *mem_ctx, const char *orig_name,
|
|
|
2fc102 |
--
|
|
|
2fc102 |
1.8.5.3
|
|
|
2fc102 |
|