Merge pull request #8939 from bryant507/main

Fix the bug of variable int32 overflow.
This commit is contained in:
Jingyu Zhou 2022-11-29 08:43:49 -08:00 committed by GitHub
commit a8dfc9d42b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -243,7 +243,7 @@ ACTOR Future<Void> read_http_response(Reference<HTTP::Response> r, Reference<ICo
auto i = r->headers.find("Content-Length");
if (i != r->headers.end())
r->contentLen = atoi(i->second.c_str());
r->contentLen = strtoll(i->second.c_str(), NULL, 10);
else
r->contentLen = -1; // Content length unknown
@ -481,7 +481,7 @@ ACTOR Future<Reference<HTTP::Response>> doRequest(Reference<IConnection> conn,
}
if (FLOW_KNOBS->HTTP_VERBOSE_LEVEL > 0) {
printf("[%s] HTTP %scode=%d early=%d, time=%fs %s %s contentLen=%d [%d out, response content len %d]\n",
printf("[%s] HTTP %scode=%d early=%d, time=%fs %s %s contentLen=%d [%d out, response content len %lld]\n",
conn->getDebugID().toString().c_str(),
(err.present() ? format("*ERROR*=%s ", err.get().name()).c_str() : ""),
r->code,
@ -491,7 +491,7 @@ ACTOR Future<Reference<HTTP::Response>> doRequest(Reference<IConnection> conn,
resource.c_str(),
contentLen,
total_sent,
(int)r->contentLen);
r->contentLen);
}
if (FLOW_KNOBS->HTTP_VERBOSE_LEVEL > 2) {
printf("[%s] HTTP RESPONSE: %s %s\n%s\n",

View File

@ -102,7 +102,7 @@ public:
// If not found, start the read.
if (i == f->m_blocks.end() || (i->second.isValid() && i->second.isError())) {
// printf("starting read of %s block %d\n", f->getFilename().c_str(), blockNum);
fblock = readBlock(f.getPtr(), f->m_block_size, f->m_block_size * blockNum);
fblock = readBlock(f.getPtr(), f->m_block_size, (int64_t)f->m_block_size * blockNum);
f->m_blocks[blockNum] = fblock;
} else
fblock = i->second;
@ -121,7 +121,7 @@ public:
// Calculate the block-relative read range. It's a given that the offset / length range touches this block
// so readStart will never be greater than blocksize (though it could be past the actual end of a short
// block).
int64_t blockStart = blockNum * f->m_block_size;
int64_t blockStart = (int64_t)blockNum * f->m_block_size;
int64_t readStart = std::max<int64_t>(0, offset - blockStart);
int64_t readEnd = std::min<int64_t>(f->m_block_size, offset + length - blockStart);
int rlen = readEnd - readStart;