1
0
mirror of https://github.com/ohwgiles/laminar.git synced 2026-11-02 08:34:44 +00:00

4 Commits
1.4 ... master

Author SHA1 Message Date
Petr Mrázek
9968f74ae9 Fix page count underflow for jobs with no completed runs
The job status page computes the number of pages as
(nRuns-1) / runsPerPage + 1 with nRuns unsigned. A job whose first
run is still in progress has no completed builds, so nRuns is 0 and
the subtraction wraps, displaying "Page 1 of 214748365". Report a
single page in that case, and add a functional test for it.
2026-11-02 11:27:47 +13:00
Silas Parker
9d928ccad8 Update Debian package libcapnp versions 2026-10-29 07:40:56 +13:00
Wesley Hershberger
e62148b5f5 Fix buffer overflow in readEnvPipe
readEnvPipe writes a null terminator to buffer[sz] without a bounds
check; if a write was >1024 the write overflows the buffer.

Signed-off-by: Wesley Hershberger <wesley.hershberger@gmail.com>
2026-09-27 11:37:50 +13:00
Wesley Hershberger
d25b7a46bb Fix memory leak in handleBadgeRequest
Signed-off-by: Wesley Hershberger <wesley.hershberger@gmail.com>
2026-09-25 13:28:28 +12:00
7 changed files with 23 additions and 7 deletions

View File

@@ -30,7 +30,7 @@ Section:
Priority: optional
Architecture: amd64
Maintainer: Oliver Giles <web ohwg net>
Depends: libcapnp-1.0.1, libsqlite3-0, zlib1g
Depends: libcapnp-1.1.0, libsqlite3-0, zlib1g
Description: Lightweight Continuous Integration Service
EOF
echo /etc/laminar.conf > laminar/DEBIAN/conffiles

View File

@@ -47,7 +47,7 @@ Section:
Priority: optional
Architecture: armhf
Maintainer: Oliver Giles <web ohwg net>
Depends: libcapnp-1.0.1, libsqlite3-0, zlib1g
Depends: libcapnp-1.1.0, libsqlite3-0, zlib1g
Description: Lightweight Continuous Integration Service
EOF
echo /etc/laminar.conf > laminar/DEBIAN/conffiles

View File

@@ -30,7 +30,7 @@ Section:
Priority: optional
Architecture: amd64
Maintainer: Oliver Giles <web ohwg net>
Depends: libcapnp-1.1.0, libsqlite3-0, zlib1g
Depends: libcapnp-1.5.0, libsqlite3-0, zlib1g
Description: Lightweight Continuous Integration Service
EOF
echo /etc/laminar.conf > laminar/DEBIAN/conffiles

View File

@@ -47,7 +47,7 @@ Section:
Priority: optional
Architecture: armhf
Maintainer: Oliver Giles <web ohwg net>
Depends: libcapnp-1.1.0, libsqlite3-0, zlib1g
Depends: libcapnp-1.5.0, libsqlite3-0, zlib1g
Description: Lightweight Continuous Integration Service
EOF
echo /etc/laminar.conf > laminar/DEBIAN/conffiles

View File

@@ -30,6 +30,7 @@
#include <fcntl.h>
#include <fnmatch.h>
#include <fstream>
#include <cstdlib>
#include <zlib.h>
#define COMPRESS_LOG_MIN_SIZE 1024
@@ -306,7 +307,7 @@ std::string Laminar::getStatus(MonitorScope scope) {
.bind(scope.job)
.fetch<uint,uint>([&](uint nRuns, uint averageRuntime){
j.set("averageRuntime", averageRuntime);
j.set("pages", (nRuns-1) / runsPerPage + 1);
j.set("pages", nRuns ? (nRuns-1) / runsPerPage + 1 : 1);
j.startObject("sort");
j.set("page", scope.page)
.set("field", scope.field)
@@ -872,6 +873,7 @@ R"x(
return false;
badge = svg;
std::free(svg);
return true;
}

View File

@@ -34,6 +34,8 @@
#include "run.h"
const int SET_ENV_BUF_SIZE = 1024;
// short syntax helper for kj::Path
template<typename T>
inline kj::Path operator/(const kj::Path& p, const T& ext) {
@@ -131,7 +133,7 @@ Leader::Leader(kj::AsyncIoContext &ioContext, kj::Filesystem &fs, const char *jo
LSYSCALL(pipe(setEnvPipe));
auto event = ioContext.lowLevelProvider->wrapInputFd(setEnvPipe[0], kj::LowLevelAsyncIoProvider::TAKE_OWNERSHIP);
auto buffer = kj::heapArrayBuilder<char>(1024);
auto buffer = kj::heapArrayBuilder<char>(SET_ENV_BUF_SIZE);
tasks.add(readEnvPipe(event, buffer.asPtr().begin()).attach(kj::mv(event), kj::mv(buffer)));
}
@@ -295,7 +297,7 @@ kj::Promise<void> Leader::reapChildProcesses()
}
kj::Promise<void> Leader::readEnvPipe(kj::AsyncInputStream *stream, char *buffer) {
return stream->tryRead(buffer, 1, 1024).then([this,stream,buffer](size_t sz) {
return stream->tryRead(buffer, 1, SET_ENV_BUF_SIZE - 1).then([this,stream,buffer](size_t sz) {
if(sz > 0) {
buffer[sz] = '\0';
if(char* eq = strchr(buffer, '=')) {

View File

@@ -163,6 +163,18 @@ TEST_F(LaminarFixture, JobDescription) {
EXPECT_STREQ("bar", data["description"].GetString());
}
TEST_F(LaminarFixture, JobPagesWithoutRuns) {
defineJob("foo", "true");
auto es = eventSource("/jobs/foo");
ioContext->waitScope.poll();
ASSERT_EQ(1, es->messages().size());
auto json = es->messages().front().GetObject();
ASSERT_TRUE(json.HasMember("data"));
auto data = json["data"].GetObject();
ASSERT_TRUE(data.HasMember("pages"));
EXPECT_EQ(1, data["pages"].GetInt());
}
TEST_F(LaminarFixture, QueueFront) {
setNumExecutors(0);
defineJob("foo", "true");