Fix: enlarge buffer when too small
This commit is contained in:
parent
cb8f1abca7
commit
3555c35457
18
src/main.cpp
18
src/main.cpp
@ -53,12 +53,20 @@ static void process(const char* path) {
|
||||
const char* tagname {"user.xdg.tags"};
|
||||
std::vector<std::string> tags;
|
||||
std::vector<char> buf(1024);
|
||||
ssize_t sz = getxattr(path, tagname, buf.data(), buf.size());
|
||||
if (sz == -1) {
|
||||
if (errno != ENODATA) {
|
||||
throw_if_min1(sz);
|
||||
ssize_t sz = 0;
|
||||
do {
|
||||
sz = getxattr(path, tagname, buf.data(), buf.size());
|
||||
if (sz == -1) {
|
||||
if (errno == ERANGE) {
|
||||
buf.resize(buf.size() * 2);
|
||||
} else if (errno == ENODATA) {
|
||||
break;
|
||||
} else {
|
||||
throw_if_min1(-1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
} while (sz == -1 && errno == ERANGE);
|
||||
if (sz > 0) {
|
||||
std::string val(buf.data(), sz);
|
||||
tags = sc::split(val, ",");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user