mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-03-02 23:18:44 +00:00
Fix some glitches in redbean
This change includes a fix to Fetch() where an out of bounds memory read could happen, when the reverse proxied endpoint omits the content-length header. This caused a bunch of NUL chars to appear on TurfWar's /statusz since it wouldn't actually overrun the buffer, and if it did it would've been caught by MODE=asan builds.
This commit is contained in:
parent
14d036b68d
commit
6b06a8176d
6 changed files with 7 additions and 7 deletions
|
@ -78,7 +78,7 @@ int poll(struct pollfd *fds, size_t nfds, int timeout_ms) {
|
|||
rc = sys_poll_nt(fds, nfds, &millis, 0);
|
||||
}
|
||||
|
||||
STRACE("poll(%s, %'zu, %'d) → %d% lm\n", DescribePollFds(rc, fds, nfds), nfds,
|
||||
STRACE("poll(%s, %'zu, %'d) → %d% lm", DescribePollFds(rc, fds, nfds), nfds,
|
||||
timeout_ms, rc);
|
||||
return rc;
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ int ppoll(struct pollfd *fds, size_t nfds, const struct timespec *timeout,
|
|||
rc = sys_poll_nt(fds, nfds, &millis, sigmask);
|
||||
}
|
||||
|
||||
STRACE("ppoll(%s, %'zu, %s, %s) → %d% lm\n", DescribePollFds(rc, fds, nfds),
|
||||
STRACE("ppoll(%s, %'zu, %s, %s) → %d% lm", DescribePollFds(rc, fds, nfds),
|
||||
nfds, DescribeTimespec(0, timeout), DescribeSigset(0, sigmask), rc);
|
||||
return rc;
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ static const struct thatispacked {
|
|||
{CAP_CHECKPOINT_RESTORE, "CHECKPOINT_RESTORE"}, //
|
||||
};
|
||||
|
||||
const char *(DescribeCapability)(char buf[20], int x) {
|
||||
const char *(DescribeCapability)(char buf[32], int x) {
|
||||
int i;
|
||||
for (i = 0; i < ARRAYLEN(kCapabilityName); ++i) {
|
||||
if (kCapabilityName[i].x == x) {
|
||||
|
|
|
@ -13,7 +13,7 @@ const char *DescribeFlags(char *, size_t, struct DescribeFlags *, size_t,
|
|||
const char *, unsigned);
|
||||
|
||||
const char *DescribeArchPrctlCode(char[12], int);
|
||||
const char *DescribeCapability(char[20], int);
|
||||
const char *DescribeCapability(char[32], int);
|
||||
const char *DescribeClockName(char[32], int);
|
||||
const char *DescribeDirfd(char[12], int);
|
||||
const char *DescribeDnotifyFlags(char[80], int);
|
||||
|
@ -67,7 +67,7 @@ const char *DescribeWhence(char[12], int);
|
|||
const char *DescribeWhichPrio(char[12], int);
|
||||
|
||||
#define DescribeArchPrctlCode(x) DescribeArchPrctlCode(alloca(12), x)
|
||||
#define DescribeCapability(x) DescribeCapability(alloca(20), x)
|
||||
#define DescribeCapability(x) DescribeCapability(alloca(32), x)
|
||||
#define DescribeClockName(x) DescribeClockName(alloca(32), x)
|
||||
#define DescribeDirfd(x) DescribeDirfd(alloca(12), x)
|
||||
#define DescribeDnotifyFlags(x) DescribeDnotifyFlags(alloca(80), x)
|
||||
|
|
|
@ -364,7 +364,7 @@ static int LuaFetch(lua_State *L) {
|
|||
break;
|
||||
case kHttpClientStateBody:
|
||||
if (!g) {
|
||||
paylen = inbuf.n;
|
||||
paylen = inbuf.n - hdrsize;
|
||||
goto Finished;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -6153,7 +6153,7 @@ static char *ServeAsset(struct Asset *a, const char *path, size_t pathlen) {
|
|||
((cpm.contentlength >= 100 && _startswithi(ct, "text/")) ||
|
||||
(cpm.contentlength >= 1000 &&
|
||||
MeasureEntropy(cpm.content, 1000) < 7))) {
|
||||
WARNF("serving compressed asset");
|
||||
VERBOSEF("serving compressed asset");
|
||||
p = ServeAssetCompressed(a);
|
||||
} else {
|
||||
p = ServeAssetIdentity(a, ct);
|
||||
|
|
Loading…
Add table
Reference in a new issue