chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
rtnl: drop "sd_" prefix from cleanup macros
[elogind.git]
/
src
/
shared
/
fileio.c
diff --git
a/src/shared/fileio.c
b/src/shared/fileio.c
index ede88196b5f1a9374a5b387a9d72278bf86255cb..b81eeb272a4bdc8aa28d89f97fce7d4d5976b977 100644
(file)
--- a/
src/shared/fileio.c
+++ b/
src/shared/fileio.c
@@
-534,35
+534,42
@@
fail:
static int parse_env_file_push(const char *filename, unsigned line,
const char *key, char *value, void *userdata) {
static int parse_env_file_push(const char *filename, unsigned line,
const char *key, char *value, void *userdata) {
- assert(utf8_is_valid(key));
- if (value && !utf8_is_valid(value))
- /* FIXME: filter UTF-8 */
- log_error("%s:%u: invalid UTF-8 for key %s: '%s', ignoring.",
- filename, line, key, value);
- else {
- const char *k;
- va_list* ap = (va_list*) userdata;
- va_list aq;
+ const char *k;
+ va_list aq, *ap = userdata;
- va_copy(aq, *ap);
+ if (!utf8_is_valid(key)) {
+ _cleanup_free_ char *p = utf8_escape_invalid(key);
- while ((k = va_arg(aq, const char *))) {
- char **v;
+ log_error("%s:%u: invalid UTF-8 in key '%s', ignoring.",
+ filename, line, p);
+ return -EINVAL;
+ }
- v = va_arg(aq, char **);
+ if (value && !utf8_is_valid(value)) {
+ _cleanup_free_ char *p = utf8_escape_invalid(value);
- if (streq(key, k)) {
- va_end(aq);
- free(*v);
- *v = value;
- return 1;
- }
- }
+ log_error("%s:%u: invalid UTF-8 value for key %s: '%s', ignoring.",
+ filename, line, key, p);
+ return -EINVAL;
+ }
+
+ va_copy(aq, *ap);
+
+ while ((k = va_arg(aq, const char *))) {
+ char **v;
- va_end(aq);
+ v = va_arg(aq, char **);
+
+ if (streq(key, k)) {
+ va_end(aq);
+ free(*v);
+ *v = value;
+ return 1;
+ }
}
}
+ va_end(aq);
free(value);
return 0;
}
free(value);
return 0;
}
@@
-586,26
+593,31
@@
int parse_env_file(
static int load_env_file_push(const char *filename, unsigned line,
const char *key, char *value, void *userdata) {
static int load_env_file_push(const char *filename, unsigned line,
const char *key, char *value, void *userdata) {
- assert(utf8_is_valid(key));
+ char ***m = userdata;
+ char *p;
+ int r;
+
+ if (!utf8_is_valid(key)) {
+ log_error("%s:%u: invalid UTF-8 for key '%s', ignoring.",
+ filename, line, key);
+ return -EINVAL;
+ }
- if (value && !utf8_is_valid(value))
+ if (value && !utf8_is_valid(value))
{
/* FIXME: filter UTF-8 */
/* FIXME: filter UTF-8 */
- log_error("%s:%u: invalid UTF-8 for key %s: '%s', ignoring.",
+ log_error("%s:%u: invalid UTF-8
value
for key %s: '%s', ignoring.",
filename, line, key, value);
filename, line, key, value);
- else {
- char ***m = userdata;
- char *p;
- int r;
+ return -EINVAL;
+ }
-
p = strjoin(key, "=", strempty(value), NULL);
-
if (!p)
-
return -ENOMEM;
+ p = strjoin(key, "=", strempty(value), NULL);
+ if (!p)
+ return -ENOMEM;
- r = strv_push(m, p);
- if (r < 0) {
- free(p);
- return r;
- }
+ r = strv_push(m, p);
+ if (r < 0) {
+ free(p);
+ return r;
}
free(value);
}
free(value);