[*] Linux DirMks shall copy the stat of the parent dir before assuming 775.

[*] Added missing null allocation checks under linux net adapter list
This commit is contained in:
Reece Wilson 2022-12-17 15:37:46 +00:00
parent 6f6be5c545
commit 9ce314a838
2 changed files with 45 additions and 8 deletions

View File

@ -26,7 +26,30 @@ namespace Aurora::IO::FS
{
bool _MkDir(const AuString &path)
{
return mkdir(path.c_str(), 0775) == 0;
AuString subdir;
if ((path.size() > 1) &&
((path[path.size() - 1] == '/') ||
(path[path.size() - 1] == '\\')))
{
subdir = path.substr(0, path.size() - 1);
}
else
{
subdir = path;
}
GoUpToSeparator(subdir, subdir);
mode_t mode { 0775 };
struct stat s;
if (::stat(path.c_str(), &s) != -1)
{
mode = s.st_mode;
}
return ::mkdir(path.c_str(), mode) == 0;
}
struct ReadDirStructure : IReadDir
@ -233,7 +256,6 @@ namespace Aurora::IO::FS
}
else
{
buffer.clear();
return true;
}
}
@ -344,28 +366,28 @@ namespace Aurora::IO::FS
int input, output;
if ((input = open(normalizedSrcPath.c_str(), O_RDONLY | O_CLOEXEC)) == -1)
if ((input = ::open(normalizedSrcPath.c_str(), O_RDONLY | O_CLOEXEC)) == -1)
{
return false;
}
struct stat fileinfo = { 0 };
if (fstat(input, &fileinfo) != 0)
if (::fstat(input, &fileinfo) != 0)
{
close(input)
return false;
}
if ((output = creat(normalizedDestPath.c_str(), fileinfo.st_mode)) == -1)
if ((output = ::creat(normalizedDestPath.c_str(), fileinfo.st_mode)) == -1)
{
close(input);
return false;
}
auto result = fcopyfile(input, output, 0, COPYFILE_ALL) == 0;
auto result = ::fcopyfile(input, output, 0, COPYFILE_ALL) == 0;
close(input);
close(output);
::close(input);
::close(output);
return result;
}

View File

@ -150,6 +150,11 @@ namespace Aurora::IO::Net
reqlen = NLMSG_SPACE(sizeof(*rt));
auto pReq = AuMakeSharedArray<AuUInt8>(kRouteBufferSize);
if (!pReq)
{
SysPushErrorMemory();
return {};
}
hdr = (struct nlmsghdr *)pReq.get();
hdr->nlmsg_len = NLMSG_LENGTH(sizeof(*rt));
@ -271,6 +276,11 @@ namespace Aurora::IO::Net
/* Allocate space for the request. */
reqlen = NLMSG_SPACE(sizeof(*ifa));
auto pReq = AuMakeSharedArray<AuUInt8>(kAddrBufferSize);
if (!pReq)
{
SysPushErrorMemory();
return {};
}
hdr = (struct nlmsghdr *)pReq.get();
hdr->nlmsg_len = NLMSG_LENGTH(sizeof(*ifa));
@ -364,6 +374,11 @@ namespace Aurora::IO::Net
auto reqlen = NLMSG_SPACE(sizeof(*ifa));
auto pReq = AuMakeSharedArray<AuUInt8>(kAddrBufferSize);
if (!pReq)
{
SysPushErrorMemory();
return;
}
hdr = (struct nlmsghdr *)pReq.get();
hdr->nlmsg_len = NLMSG_LENGTH(sizeof(*ifa));