chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
bus-proxy: policy - ignore unsupported tags and attributes
[elogind.git]
/
src
/
shared
/
fileio.c
diff --git
a/src/shared/fileio.c
b/src/shared/fileio.c
index b81eeb272a4bdc8aa28d89f97fce7d4d5976b977..c7b2cd85b94b8cc0eacc452fb70c5e4ed4f3e0df 100644
(file)
--- a/
src/shared/fileio.c
+++ b/
src/shared/fileio.c
@@
-130,7
+130,7
@@
ssize_t sendfile_full(int out_fd, const char *fn) {
assert(out_fd > 0);
assert(fn);
assert(out_fd > 0);
assert(fn);
- f = fopen(fn, "r");
+ f = fopen(fn, "r
e
");
if (!f)
return -errno;
if (!f)
return -errno;
@@
-294,7
+294,7
@@
static int parse_env_file_internal(
state = KEY;
last_key_whitespace = (size_t) -1;
state = KEY;
last_key_whitespace = (size_t) -1;
- if (!
greedy_realloc((void**) &key, &
key_alloc, n_key+2)) {
+ if (!
GREEDY_REALLOC(key,
key_alloc, n_key+2)) {
r = -ENOMEM;
goto fail;
}
r = -ENOMEM;
goto fail;
}
@@
-317,7
+317,7
@@
static int parse_env_file_internal(
else if (last_key_whitespace == (size_t) -1)
last_key_whitespace = n_key;
else if (last_key_whitespace == (size_t) -1)
last_key_whitespace = n_key;
- if (!
greedy_realloc((void**) &key, &
key_alloc, n_key+2)) {
+ if (!
GREEDY_REALLOC(key,
key_alloc, n_key+2)) {
r = -ENOMEM;
goto fail;
}
r = -ENOMEM;
goto fail;
}
@@
-357,7
+357,7
@@
static int parse_env_file_internal(
else if (!strchr(WHITESPACE, c)) {
state = VALUE;
else if (!strchr(WHITESPACE, c)) {
state = VALUE;
- if (!
greedy_realloc((void**) &value, &
value_alloc, n_value+2)) {
+ if (!
GREEDY_REALLOC(value,
value_alloc, n_value+2)) {
r = -ENOMEM;
goto fail;
}
r = -ENOMEM;
goto fail;
}
@@
-402,7
+402,7
@@
static int parse_env_file_internal(
else if (last_value_whitespace == (size_t) -1)
last_value_whitespace = n_value;
else if (last_value_whitespace == (size_t) -1)
last_value_whitespace = n_value;
- if (!
greedy_realloc((void**) &value, &
value_alloc, n_value+2)) {
+ if (!
GREEDY_REALLOC(value,
value_alloc, n_value+2)) {
r = -ENOMEM;
goto fail;
}
r = -ENOMEM;
goto fail;
}
@@
-417,7
+417,7
@@
static int parse_env_file_internal(
if (!strchr(newline, c)) {
/* Escaped newlines we eat up entirely */
if (!strchr(newline, c)) {
/* Escaped newlines we eat up entirely */
- if (!
greedy_realloc((void**) &value, &
value_alloc, n_value+2)) {
+ if (!
GREEDY_REALLOC(value,
value_alloc, n_value+2)) {
r = -ENOMEM;
goto fail;
}
r = -ENOMEM;
goto fail;
}
@@
-432,7
+432,7
@@
static int parse_env_file_internal(
else if (c == '\\')
state = SINGLE_QUOTE_VALUE_ESCAPE;
else {
else if (c == '\\')
state = SINGLE_QUOTE_VALUE_ESCAPE;
else {
- if (!
greedy_realloc((void**) &value, &
value_alloc, n_value+2)) {
+ if (!
GREEDY_REALLOC(value,
value_alloc, n_value+2)) {
r = -ENOMEM;
goto fail;
}
r = -ENOMEM;
goto fail;
}
@@
-446,7
+446,7
@@
static int parse_env_file_internal(
state = SINGLE_QUOTE_VALUE;
if (!strchr(newline, c)) {
state = SINGLE_QUOTE_VALUE;
if (!strchr(newline, c)) {
- if (!
greedy_realloc((void**) &value, &
value_alloc, n_value+2)) {
+ if (!
GREEDY_REALLOC(value,
value_alloc, n_value+2)) {
r = -ENOMEM;
goto fail;
}
r = -ENOMEM;
goto fail;
}
@@
-461,7
+461,7
@@
static int parse_env_file_internal(
else if (c == '\\')
state = DOUBLE_QUOTE_VALUE_ESCAPE;
else {
else if (c == '\\')
state = DOUBLE_QUOTE_VALUE_ESCAPE;
else {
- if (!
greedy_realloc((void**) &value, &
value_alloc, n_value+2)) {
+ if (!
GREEDY_REALLOC(value,
value_alloc, n_value+2)) {
r = -ENOMEM;
goto fail;
}
r = -ENOMEM;
goto fail;
}
@@
-475,7
+475,7
@@
static int parse_env_file_internal(
state = DOUBLE_QUOTE_VALUE;
if (!strchr(newline, c)) {
state = DOUBLE_QUOTE_VALUE;
if (!strchr(newline, c)) {
- if (!
greedy_realloc((void**) &value, &
value_alloc, n_value+2)) {
+ if (!
GREEDY_REALLOC(value,
value_alloc, n_value+2)) {
r = -ENOMEM;
goto fail;
}
r = -ENOMEM;
goto fail;
}
@@
-598,15
+598,18
@@
static int load_env_file_push(const char *filename, unsigned line,
int r;
if (!utf8_is_valid(key)) {
int r;
if (!utf8_is_valid(key)) {
+ _cleanup_free_ char *t = utf8_escape_invalid(key);
+
log_error("%s:%u: invalid UTF-8 for key '%s', ignoring.",
log_error("%s:%u: invalid UTF-8 for key '%s', ignoring.",
- filename, line,
key
);
+ filename, line,
t
);
return -EINVAL;
}
if (value && !utf8_is_valid(value)) {
return -EINVAL;
}
if (value && !utf8_is_valid(value)) {
- /* FIXME: filter UTF-8 */
+ _cleanup_free_ char *t = utf8_escape_invalid(value);
+
log_error("%s:%u: invalid UTF-8 value 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,
t
);
return -EINVAL;
}
return -EINVAL;
}
@@
-614,11
+617,9
@@
static int load_env_file_push(const char *filename, unsigned line,
if (!p)
return -ENOMEM;
if (!p)
return -ENOMEM;
- r = strv_push(m, p);
- if (r < 0) {
- free(p);
+ r = strv_consume(m, p);
+ if (r < 0)
return r;
return r;
- }
free(value);
return 0;
free(value);
return 0;