xattr-util: rework getxattr_at_malloc()
Let's return the size in a return parameter instead of the return value. And if NULL is specified this tells us the caller doesn't care about the size and expects a NUL terminated string. In that case look for an embedded NUL byte, and refuse in that case. This should lock things down a bit, as we'll systematically refuse embedded NUL strings now when we expect strings.
This commit is contained in:
@@ -723,7 +723,7 @@ int cg_get_xattr(const char *path, const char *name, void *value, size_t size) {
|
||||
return (int) n;
|
||||
}
|
||||
|
||||
int cg_get_xattr_malloc(const char *path, const char *name, char **ret) {
|
||||
int cg_get_xattr_malloc(const char *path, const char *name, char **ret, size_t *ret_size) {
|
||||
_cleanup_free_ char *fs = NULL;
|
||||
int r;
|
||||
|
||||
@@ -734,7 +734,7 @@ int cg_get_xattr_malloc(const char *path, const char *name, char **ret) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return lgetxattr_malloc(fs, name, ret);
|
||||
return lgetxattr_malloc(fs, name, ret, ret_size);
|
||||
}
|
||||
|
||||
int cg_get_xattr_bool(const char *path, const char *name) {
|
||||
|
||||
Reference in New Issue
Block a user