tree-wide: make cunescape*() functions return ssize_t
Strictly speaking, we are returning the size of a memory chunk of arbitrary size, so ssize_t is more appropriate than int.
This commit is contained in:
@@ -426,6 +426,7 @@ int bpf_program_deserialize_attachment(const char *v, FDSet *fds, BPFProgram **b
|
||||
_cleanup_free_ char *sfd = NULL, *sat = NULL, *unescaped = NULL;
|
||||
_cleanup_(bpf_program_unrefp) BPFProgram *p = NULL;
|
||||
_cleanup_close_ int fd = -1;
|
||||
ssize_t l;
|
||||
int ifd, at, r;
|
||||
|
||||
assert(v);
|
||||
@@ -456,9 +457,9 @@ int bpf_program_deserialize_attachment(const char *v, FDSet *fds, BPFProgram **b
|
||||
return at;
|
||||
|
||||
/* The rest is the path */
|
||||
r = cunescape(v, 0, &unescaped);
|
||||
if (r < 0)
|
||||
return r;
|
||||
l = cunescape(v, 0, &unescaped);
|
||||
if (l < 0)
|
||||
return l;
|
||||
|
||||
fd = fdset_remove(fds, ifd);
|
||||
if (fd < 0)
|
||||
|
||||
@@ -1096,7 +1096,7 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con
|
||||
r = sd_bus_message_append_array(m, 'y', decoded, decoded_size);
|
||||
} else {
|
||||
_cleanup_free_ char *unescaped = NULL;
|
||||
int l;
|
||||
ssize_t l;
|
||||
|
||||
l = cunescape(p, UNESCAPE_ACCEPT_NUL, &unescaped);
|
||||
if (l < 0)
|
||||
@@ -1233,18 +1233,19 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con
|
||||
|
||||
if (streq(field, "StandardInputText")) {
|
||||
_cleanup_free_ char *unescaped = NULL;
|
||||
ssize_t l;
|
||||
|
||||
r = cunescape(eq, 0, &unescaped);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to unescape text '%s': %m", eq);
|
||||
l = cunescape(eq, 0, &unescaped);
|
||||
if (l < 0)
|
||||
return log_error_errno(l, "Failed to unescape text '%s': %m", eq);
|
||||
|
||||
if (!strextend(&unescaped, "\n"))
|
||||
return log_oom();
|
||||
|
||||
/* Note that we don't expand specifiers here, but that should be OK, as this is a programmatic
|
||||
* interface anyway */
|
||||
/* Note that we don't expand specifiers here, but that should be OK, as this is a
|
||||
* programmatic interface anyway */
|
||||
|
||||
return bus_append_byte_array(m, field, unescaped, strlen(unescaped));
|
||||
return bus_append_byte_array(m, field, unescaped, l + 1);
|
||||
}
|
||||
|
||||
if (streq(field, "StandardInputData")) {
|
||||
|
||||
@@ -220,9 +220,11 @@ int devnode_acl_all(const char *seat,
|
||||
if (dir) {
|
||||
FOREACH_DIRENT(dent, dir, return -errno) {
|
||||
_cleanup_free_ char *unescaped_devname = NULL;
|
||||
ssize_t l;
|
||||
|
||||
if (cunescape(dent->d_name, UNESCAPE_RELAX, &unescaped_devname) < 0)
|
||||
return -ENOMEM;
|
||||
l = cunescape(dent->d_name, UNESCAPE_RELAX, &unescaped_devname);
|
||||
if (l < 0)
|
||||
return l;
|
||||
|
||||
n = path_join("/dev", unescaped_devname);
|
||||
if (!n)
|
||||
|
||||
@@ -176,6 +176,7 @@ int deserialize_dual_timestamp(const char *value, dual_timestamp *t) {
|
||||
|
||||
int deserialize_environment(const char *value, char ***list) {
|
||||
_cleanup_free_ char *unescaped = NULL;
|
||||
ssize_t l;
|
||||
int r;
|
||||
|
||||
assert(value);
|
||||
@@ -183,9 +184,9 @@ int deserialize_environment(const char *value, char ***list) {
|
||||
|
||||
/* Changes the *environment strv inline. */
|
||||
|
||||
r = cunescape(value, 0, &unescaped);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to unescape: %m");
|
||||
l = cunescape(value, 0, &unescaped);
|
||||
if (l < 0)
|
||||
return log_error_errno(l, "Failed to unescape: %m");
|
||||
|
||||
r = strv_env_replace_consume(list, TAKE_PTR(unescaped));
|
||||
if (r < 0)
|
||||
|
||||
@@ -351,7 +351,6 @@ void log_device_uevent(sd_device *device, const char *str) {
|
||||
|
||||
int udev_rule_parse_value(char *str, char **ret_value, char **ret_endpos) {
|
||||
char *i, *j;
|
||||
int r;
|
||||
bool is_escaped;
|
||||
|
||||
/* value must be double quotated */
|
||||
@@ -373,6 +372,7 @@ int udev_rule_parse_value(char *str, char **ret_value, char **ret_endpos) {
|
||||
j[0] = '\0';
|
||||
} else {
|
||||
_cleanup_free_ char *unescaped = NULL;
|
||||
ssize_t l;
|
||||
|
||||
/* find the end position of value */
|
||||
for (i = str; *i != '"'; i++) {
|
||||
@@ -383,11 +383,12 @@ int udev_rule_parse_value(char *str, char **ret_value, char **ret_endpos) {
|
||||
}
|
||||
i[0] = '\0';
|
||||
|
||||
r = cunescape_length(str, i - str, 0, &unescaped);
|
||||
if (r < 0)
|
||||
return r;
|
||||
assert(r <= i - str);
|
||||
memcpy(str, unescaped, r + 1);
|
||||
l = cunescape_length(str, i - str, 0, &unescaped);
|
||||
if (l < 0)
|
||||
return l;
|
||||
|
||||
assert(l <= i - str);
|
||||
memcpy(str, unescaped, l + 1);
|
||||
}
|
||||
|
||||
*ret_value = str;
|
||||
|
||||
Reference in New Issue
Block a user