xattr-util: document that we NUL suffix
This commit is contained in:
@@ -27,7 +27,7 @@ int getxattr_malloc(const char *path, const char *name, char **value, bool allow
|
||||
assert(name);
|
||||
assert(value);
|
||||
|
||||
for (l = 100; ; l = (size_t) n + 1) {
|
||||
for (l = 100; ; l = (size_t) n + 1 /* extra byte to make sure this remains NUL suffixed */) {
|
||||
v = new0(char, l);
|
||||
if (!v)
|
||||
return -ENOMEM;
|
||||
@@ -36,7 +36,6 @@ int getxattr_malloc(const char *path, const char *name, char **value, bool allow
|
||||
n = lgetxattr(path, name, v, l);
|
||||
else
|
||||
n = getxattr(path, name, v, l);
|
||||
|
||||
if (n >= 0 && (size_t) n < l) {
|
||||
*value = v;
|
||||
return n;
|
||||
@@ -65,13 +64,12 @@ int fgetxattr_malloc(int fd, const char *name, char **value) {
|
||||
assert(name);
|
||||
assert(value);
|
||||
|
||||
for (l = 100; ; l = (size_t) n + 1) {
|
||||
for (l = 100;; l = (size_t) n + 1 /* extra byte to make sure this remains NUL suffixed */) {
|
||||
v = new0(char, l);
|
||||
if (!v)
|
||||
return -ENOMEM;
|
||||
|
||||
n = fgetxattr(fd, name, v, l);
|
||||
|
||||
if (n >= 0 && (size_t) n < l) {
|
||||
*value = v;
|
||||
return n;
|
||||
|
||||
Reference in New Issue
Block a user