Libgourou

Libgourou Commit Details

Date:2022-12-23 17:51:51 (8 months 30 days ago)
Author:Grégory Soutadé
Branch:master
Commit:c41dd46ca7aa024f057895eda52a9f6b8ea280a7
Parents: e4bd73c03db20e8c6dacb53b51eae2e5244a82f7
Message:Check for potential write error (or not buffer fully consumed)

Changes:
Msrc/libgourou.cpp (1 diff)
Mutils/utils_common.cpp (2 diffs)

File differences

src/libgourou.cpp
931931
932932
933933
934
935
934936
935937
936938
937939
938940
939
940
941
941942
943
944
945
946
942947
943948
944949
void DRMProcessor::exportPrivateLicenseKey(std::string path)
{
int fd = open(path.c_str(), O_CREAT|O_TRUNC|O_WRONLY, S_IRWXU);
int ret;
if (fd <= 0)
EXCEPTION(GOUROU_FILE_ERROR, "Unable to open " << path);
ByteArray privateLicenseKey = ByteArray::fromBase64(user->getPrivateLicenseKey());
/* In adobekey.py, we get base64 decoded data [26:] */
write(fd, privateLicenseKey.data()+26, privateLicenseKey.length()-26);
ret = write(fd, privateLicenseKey.data()+26, privateLicenseKey.length()-26);
close(fd);
if (ret != privateLicenseKey.length()-26)
{
EXCEPTION(gourou::GOUROU_FILE_ERROR, "Error writing " << path);
}
}
int DRMProcessor::getLogLevel() {return (int)gourou::logLevel;}
utils/utils_common.cpp
9999
100100
101101
102
102
103103
104104
105105
......
119119
120120
121121
122
122
123
124
125
126
127
128
129
130
131
132
133
134
123135
124136
125137
void fileCopy(const char* in, const char* out)
{
char buffer[4096];
int ret, fdIn, fdOut;
int ret, ret2, fdIn, fdOut;
fdIn = open(in, O_RDONLY);
ret = ::read(fdIn, buffer, sizeof(buffer));
if (ret <= 0)
break;
::write(fdOut, buffer, ret);
do
{
ret2 = ::write(fdOut, buffer, ret);
if (ret2 >= 0)
{
ret -= ret2;
buffer += ret2;
}
else
{
EXCEPTION(gourou::CLIENT_FILE_ERROR, "Error writing " << out);
}
} while (ret);
}
close (fdIn);

Archive Download the corresponding diff file