listattr: Make sure attributes are properly terminated

* This reduces garbage in the output, especially with 0 byte string
  types.
This commit is contained in:
Axel Dörfler
2020-05-12 14:01:10 +02:00
parent 95e5e933ab
commit 194b772d8c
+2 -1
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2004-2015, Axel Dörfler, [email protected]. * Copyright 2004-2020, Axel Dörfler, [email protected].
* Copyright 2002, Ryan Fleet. * Copyright 2002, Ryan Fleet.
* *
* Distributed under the terms of the MIT license. * Distributed under the terms of the MIT license.
@@ -76,6 +76,7 @@ show_attr_contents(BNode& node, const char* attribute, const attr_info& info)
size); size);
return; return;
} }
buffer[min_c(bytesRead, kLimit - 1)] = '\0';
switch (info.type) { switch (info.type) {
case B_INT8_TYPE: case B_INT8_TYPE: