tools/stat: correctly test errno for buffer doubling

This commit is contained in:
Danny Robson 2019-04-25 14:19:30 +10:00
parent 4d538190f2
commit d9f9ca9a43

View File

@ -120,7 +120,12 @@ void do_xattr (char const *path)
while (true) { while (true) {
auto const res = getxattr (path, keybuffer.c_str (), val.data (), val.size ()); auto const res = getxattr (path, keybuffer.c_str (), val.data (), val.size ());
if (res == E2BIG) { if (res < 0 && errno == E2BIG) {
val = "___E2BIG";
break;
}
if (res < 0 && errno == ERANGE) {
val.resize (val.size () * 2); val.resize (val.size () * 2);
continue; continue;
} }