mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-09-01 09:51:13 +02:00
hdd_menu: improve error resilience in getFmtType()
Origin commit data
------------------
Branch: ni/coolstream
Commit: 2f09cf0a2f
Author: Stefan Seyfried <seife@tuxbox-git.slipkontur.de>
Date: 2014-02-23 (Sun, 23 Feb 2014)
------------------
No further description and justification available within origin commit message!
------------------
This commit was generated by Migit
This commit is contained in:
@@ -111,14 +111,18 @@ std::string getFmtType(const char* name, int num)
|
|||||||
FILE* f = my_popen(pid, pcmd.c_str(), "r");
|
FILE* f = my_popen(pid, pcmd.c_str(), "r");
|
||||||
if (f != NULL) {
|
if (f != NULL) {
|
||||||
char buff[512];
|
char buff[512];
|
||||||
fgets(buff, sizeof(buff), f);
|
if (!fgets(buff, sizeof(buff), f))
|
||||||
|
buff[0] = '\0';
|
||||||
fclose(f);
|
fclose(f);
|
||||||
ret = buff;
|
ret = buff;
|
||||||
std::string search = "TYPE=\"";
|
std::string search = "TYPE=\"";
|
||||||
size_t pos = ret.find(search);
|
size_t pos = ret.find(search);
|
||||||
|
if (pos == std::string::npos)
|
||||||
|
return "";
|
||||||
ret = ret.substr(pos + search.length());
|
ret = ret.substr(pos + search.length());
|
||||||
pos = ret.find("\"");
|
pos = ret.find("\"");
|
||||||
ret = ret.substr(0, pos);
|
if (pos != std::string::npos)
|
||||||
|
ret = ret.substr(0, pos);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user