Gitweb links:
...log
http://git.netsurf-browser.org/netsurf.git/shortlog/bbb9b4ab7238fac41a06be62a6d3c4d5fc82e829
...commit
http://git.netsurf-browser.org/netsurf.git/commit/bbb9b4ab7238fac41a06be62a6d3c4d5fc82e829
...tree
http://git.netsurf-browser.org/netsurf.git/tree/bbb9b4ab7238fac41a06be62a6d3c4d5fc82e829
The branch, master has been updated
via bbb9b4ab7238fac41a06be62a6d3c4d5fc82e829 (commit)
via 922abd7bff03a75f41788596e9398ba6e03c2ac6 (commit)
via dfcdf8d17d237a484bf98b009e6649039ad33436 (commit)
via d1610a1cdb3c62e45cdffc3032abaa7700228c73 (commit)
via ce6a2c87da8ca2c81b0cab272e0f21906e643c85 (commit)
via 6c4343a742c70ee8adb6ff7b1ab476976955e58c (commit)
via ef00567b029ec007ceab342a2ed1addaa5f63be6 (commit)
via 5fed462e88c8ec7ec25a668afa5b3f4b94eea4bb (commit)
via 836b5b61267e23872f6ce04ed6766c14ecebdf9e (commit)
via a584c6bb3bc529043e26faed01b61cf56a39d4a7 (commit)
via 743817c205be630cb46e4a2cef4da802b1f9084a (commit)
via cb5d63768c57a9428f961d340b1ff86a3289d581 (commit)
via c50f4bab09779bf5bbc191701128be3affd9a2dc (commit)
from cd3b4487c7b5e200c8bdfebe0818d59c6b7aaf8a (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=bbb9b4ab7238fac41a06be62a6d3c4d5fc82e829
commit bbb9b4ab7238fac41a06be62a6d3c4d5fc82e829
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
GitHub CI: Add monkey short-internet test
diff --git a/.github/workflows/monkey-test.yaml
b/.github/workflows/monkey-test.yaml
new file mode 100644
index 0000000..5f93e35
--- /dev/null
+++ b/.github/workflows/monkey-test.yaml
@@ -0,0 +1,62 @@
+name: "Monkey Test"
+
+on: [pull_request]
+
+jobs:
+ test:
+ name: '${{ matrix.test }}'
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ test:
+ - short-internet
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v3
+ with:
+ fetch-depth: 1
+
+ - name: apt-get install packages
+ run: sudo apt-get update -qq &&
+ sudo apt-get install --no-install-recommends -y
+ bison
+ build-essential
+ check
+ clang
+ flex
+ git
+ gperf
+ libcurl4-openssl-dev
+ libgtk-3-dev
+ libhtml-parser-perl
+ libjpeg-dev
+ libpng-dev
+ librsvg2-dev
+ llvm
+ pkg-config
+ wbritish # Needed for `/usr/share/dict/words`, used by test
+
+ - name: Build and install project libs
+ run: |
+ export TARGET_WORKSPACE="$(pwd)/projects"
+ source docs/env.sh
+ ns-clone -n -s
+ ns-make-tools install
+ ns-make-libs install
+
+ - name: Disable -Werror
+ # We can remove this step if we ever move to GitHub properly.
+ run: |
+ find . -type f -name Makefile | xargs sed -i 's/-Werror//'
+
+ - name: Build NetSurf Monkey
+ run: |
+ export TARGET_WORKSPACE="$(pwd)/projects"
+ source docs/env.sh
+ make -j"$(nproc)" TARGET=monkey
+
+ - name: Run Monkey Test
+ run: |
+ LC_ALL=C.UTF-8 test/monkey-see-monkey-do -v -d ${{ matrix.test }}
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=922abd7bff03a75f41788596e9398ba6e03c2ac6
commit 922abd7bff03a75f41788596e9398ba6e03c2ac6
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
GitHub CI: Add linux build and unit test job
diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
new file mode 100644
index 0000000..69528c9
--- /dev/null
+++ b/.github/workflows/build.yaml
@@ -0,0 +1,104 @@
+name: "Linux Build"
+
+on: [push]
+
+jobs:
+ linux:
+ name: '${{ matrix.os }}: ${{ matrix.compiler.vendor }}'
+ runs-on: ${{ matrix.os }}
+ strategy:
+ fail-fast: false
+ matrix:
+ os:
+ - ubuntu-22.04
+ - ubuntu-20.04
+ compiler:
+ # The NetSurf build system can't find LLVM AR (it looks for it
+ # in /usr/lib instead of /usr/bin:
+ # `make: /usr/lib/llvm-ar: No such file or directory`).
+ # So we need to make it explicit for llvm.
+ - { vendor: gnu, CC: gcc }
+ - { vendor: llvm, CC: clang, AR: llvm-ar }
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v3
+ with:
+ fetch-depth: 1
+
+ - name: apt-get install packages
+ run: sudo apt-get update -qq &&
+ sudo apt-get install --no-install-recommends -y
+ bison
+ build-essential
+ check
+ clang
+ flex
+ git
+ gperf
+ libcurl4-openssl-dev
+ libgtk-3-dev
+ libhtml-parser-perl
+ libjpeg-dev
+ libpng-dev
+ librsvg2-dev
+ llvm
+ pkg-config
+ wbritish # Needed for `/usr/share/dict/words`, used by test
+
+ - name: Build and install project libs
+ env:
+ CC: ${{ matrix.compiler.CC }}
+ CXX: ${{ matrix.compiler.CXX }}
+ run: |
+ export TARGET_WORKSPACE="$(pwd)/projects"
+ source docs/env.sh
+ ns-clone -n -s
+ ns-make-tools install
+ ns-make-libs install
+
+ - name: Disable -Werror
+ # We can remove this step if we ever move to GitHub properly.
+ run: |
+ find . -type f -name Makefile | xargs sed -i 's/-Werror//'
+
+ - name: Unit Tests
+ # Fails when built with clang:
+ # test/corestrings.c:58:F:corestrings:corestrings_test:486:
+ # Assertion 'ires == NSERROR_NOMEM' failed: ires == 0, NSERROR_NOMEM ==
2
+ # Looks like `malloc_limit()` not working.
+ if: ${{ matrix.compiler.vendor != 'llvm' }}
+ env:
+ CC: ${{ matrix.compiler.CC }}
+ CXX: ${{ matrix.compiler.CXX }}
+ run: |
+ export TARGET_WORKSPACE="$(pwd)/projects"
+ source docs/env.sh
+ make test
+
+ - name: Build NetSurf GTK
+ env:
+ CC: ${{ matrix.compiler.CC }}
+ CXX: ${{ matrix.compiler.CXX }}
+ run: |
+ export TARGET_WORKSPACE="$(pwd)/projects"
+ source docs/env.sh
+ make -j"$(nproc)" TARGET=gtk
+
+ - name: Build NetSurf Monkey
+ env:
+ CC: ${{ matrix.compiler.CC }}
+ CXX: ${{ matrix.compiler.CXX }}
+ run: |
+ export TARGET_WORKSPACE="$(pwd)/projects"
+ source docs/env.sh
+ make -j"$(nproc)" TARGET=monkey
+
+ - name: Build NetSurf Framebuffer
+ env:
+ CC: ${{ matrix.compiler.CC }}
+ CXX: ${{ matrix.compiler.CXX }}
+ run: |
+ export TARGET_WORKSPACE="$(pwd)/projects"
+ source docs/env.sh
+ make -j"$(nproc)" TARGET=framebuffer
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=dfcdf8d17d237a484bf98b009e6649039ad33436
commit dfcdf8d17d237a484bf98b009e6649039ad33436
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
GitHub CI: Add static analysis.
diff --git a/.github/workflows/static-analysis.yaml
b/.github/workflows/static-analysis.yaml
new file mode 100644
index 0000000..3f92548
--- /dev/null
+++ b/.github/workflows/static-analysis.yaml
@@ -0,0 +1,58 @@
+name: "Static Analysis"
+
+on: [push]
+
+jobs:
+ codeql:
+ name: Analyze with CodeQL
+ runs-on: ubuntu-22.04
+
+ strategy:
+ fail-fast: false
+ matrix:
+ language: ['cpp']
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v2
+ with:
+ fetch-depth: 1
+
+ - name: apt-get install packages
+ run: sudo apt-get update -qq &&
+ sudo apt-get install --no-install-recommends -y
+ bison
+ build-essential
+ flex
+ git
+ gperf
+ libcurl4-openssl-dev
+ libgtk-3-dev
+ libhtml-parser-perl
+ libjpeg-dev
+ libpng-dev
+ librsvg2-dev
+ pkg-config
+
+ - name: Build and install project libs
+ run: |
+ export TARGET_WORKSPACE="$(pwd)/projects"
+ source docs/env.sh
+ ns-clone -n -s
+ ns-make-tools install
+ ns-make-libs install
+
+ # Initializes the CodeQL tools for scanning.
+ - name: Initialize CodeQL
+ uses: github/codeql-action/init@v2
+ with:
+ languages: ${{ matrix.language }}
+
+ - name: Build NetSurf
+ run: |
+ export TARGET_WORKSPACE="$(pwd)/projects"
+ source docs/env.sh
+ make -j"$(nproc)"
+
+ - name: Perform CodeQL Analysis
+ uses: github/codeql-action/analyze@v2
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=d1610a1cdb3c62e45cdffc3032abaa7700228c73
commit d1610a1cdb3c62e45cdffc3032abaa7700228c73
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
env.sh: Add NetSurf clone skip and shallow clone switches.
diff --git a/docs/env.sh b/docs/env.sh
index 80292a4..a9e52a3 100644
--- a/docs/env.sh
+++ b/docs/env.sh
@@ -344,19 +344,40 @@ ns-pull()
# clone all repositories
ns-clone()
{
+ SHALLOW=""
+ while [ $# -gt 0 ]
+ do
+ case "$1" in
+ -n | --not-netsurf) NS_BROWSER=
+ shift
+ ;;
+ -s | --shallow) SHALLOW="--depth 1"
+ shift
+ ;;
+ -*) echo "Error: Unknown option: $1" >&2
+ exit 1
+ ;;
+ *) # No more options
+ break
+ ;;
+ esac
+ done
+
mkdir -p ${TARGET_WORKSPACE}
for REPO in $(echo ${NS_BUILDSYSTEM} ${NS_INTERNAL_LIBS}
${NS_FRONTEND_LIBS} ${NS_RISCOS_LIBS} ${NS_TOOLS} ${NS_BROWSER}) ; do
echo -n " GIT: Cloning ${REPO}: "
if [ -f ${TARGET_WORKSPACE}/${REPO}/.git/config ]; then
echo "Repository already present"
else
- (cd ${TARGET_WORKSPACE} && git clone ${NS_GIT}/${REPO}.git; )
+ (cd ${TARGET_WORKSPACE} && git clone ${SHALLOW}
${NS_GIT}/${REPO}.git; )
fi
done
# put current env.sh in place in workspace
- if [ ! -f "${TARGET_WORKSPACE}/env.sh" -a -f
${TARGET_WORKSPACE}/${NS_BROWSER}/docs/env.sh ]; then
- cp ${TARGET_WORKSPACE}/${NS_BROWSER}/docs/env.sh
${TARGET_WORKSPACE}/env.sh
+ if [ "x$NS_BROWSER" = "x" ]; then
+ if [ ! -f "${TARGET_WORKSPACE}/env.sh" -a -f
${TARGET_WORKSPACE}/${NS_BROWSER}/docs/env.sh ]; then
+ cp ${TARGET_WORKSPACE}/${NS_BROWSER}/docs/env.sh
${TARGET_WORKSPACE}/env.sh
+ fi
fi
}
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=ce6a2c87da8ca2c81b0cab272e0f21906e643c85
commit ce6a2c87da8ca2c81b0cab272e0f21906e643c85
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
content: image cache: Avoid int overflow before size_t conversion
diff --git a/content/handlers/image/image_cache.c
b/content/handlers/image/image_cache.c
index ae53192..8f7ff89 100644
--- a/content/handlers/image/image_cache.c
+++ b/content/handlers/image/image_cache.c
@@ -528,7 +528,7 @@ nserror image_cache_add(struct content *content,
image_cache__link(centry);
centry->content = content;
- centry->bitmap_size = content->width * content->height * 4;
+ centry->bitmap_size = content->width * content->height * 4llu;
}
NSLOG(netsurf, INFO, "centry %p, content %p, bitmap %p", centry,
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=6c4343a742c70ee8adb6ff7b1ab476976955e58c
commit 6c4343a742c70ee8adb6ff7b1ab476976955e58c
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
utils: ssl_certs: Fix potential snprintf overflow
diff --git a/utils/ssl_certs.c b/utils/ssl_certs.c
index d0f2a6c..8546165 100644
--- a/utils/ssl_certs.c
+++ b/utils/ssl_certs.c
@@ -248,12 +248,23 @@ nserror cert_chain_to_query(struct cert_chain *chain,
struct nsurl **url_out )
urlstrlen = snprintf((char *)urlstr, allocsize, "about:certificate");
for (depth = 0; depth < chain->depth; depth++) {
+ int written;
nsuerror nsures;
size_t output_length;
- urlstrlen += snprintf((char *)urlstr + urlstrlen,
- allocsize - urlstrlen,
- "&cert=");
+ written = snprintf((char *)urlstr + urlstrlen,
+ allocsize - urlstrlen,
+ "&cert=");
+ if (written < 0) {
+ free(urlstr);
+ return NSERROR_UNKNOWN;
+ }
+ if ((size_t)written >= allocsize - urlstrlen) {
+ free(urlstr);
+ return NSERROR_UNKNOWN;
+ }
+
+ urlstrlen += (size_t)written;
output_length = allocsize - urlstrlen;
nsures = nsu_base64_encode_url(
@@ -268,10 +279,20 @@ nserror cert_chain_to_query(struct cert_chain *chain,
struct nsurl **url_out )
urlstrlen += output_length;
if (chain->certs[depth].err != SSL_CERT_ERR_OK) {
- urlstrlen += snprintf((char *)urlstr + urlstrlen,
- allocsize - urlstrlen,
- "&certerr=%d",
- chain->certs[depth].err);
+ written = snprintf((char *)urlstr + urlstrlen,
+ allocsize - urlstrlen,
+ "&certerr=%d",
+ chain->certs[depth].err);
+ if (written < 0) {
+ free(urlstr);
+ return NSERROR_UNKNOWN;
+ }
+ if ((size_t)written >= allocsize - urlstrlen) {
+ free(urlstr);
+ return NSERROR_UNKNOWN;
+ }
+
+ urlstrlen += (size_t)written;
}
}
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=ef00567b029ec007ceab342a2ed1addaa5f63be6
commit ef00567b029ec007ceab342a2ed1addaa5f63be6
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
utils: file: Use fstatat and unlinkat
diff --git a/utils/file.c b/utils/file.c
index c460e49..3cf12d5 100644
--- a/utils/file.c
+++ b/utils/file.c
@@ -26,6 +26,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
+#include <fcntl.h>
#include <errno.h>
#include "desktop/gui_internal.h"
@@ -322,12 +323,23 @@ netsurf_recursive_rm(const char *path)
int nentries, ent;
nserror ret = NSERROR_OK;
struct stat ent_stat; /* stat result of leaf entry */
- char *leafpath = NULL;
const char *leafname;
+ int dirfd;
- nentries = scandir(path, &listing, 0, alphasort);
+ dirfd = open(path, O_DIRECTORY);
+ if (dirfd == -1) {
+ switch (errno) {
+ case ENOENT:
+ return NSERROR_NOT_FOUND;
+ default:
+ return NSERROR_UNKNOWN;
+ }
+ }
+ nentries = scandir(path, &listing, 0, alphasort);
if (nentries < 0) {
+ close(dirfd);
+
switch (errno) {
case ENOENT:
return NSERROR_NOT_FOUND;
@@ -341,21 +353,26 @@ netsurf_recursive_rm(const char *path)
if (strcmp(leafname, ".") == 0 ||
strcmp(leafname, "..") == 0)
continue;
- ret = netsurf_mkpath(&leafpath, NULL, 2, path, leafname);
- if (ret != NSERROR_OK) goto out;
- if (stat(leafpath, &ent_stat) != 0) {
+ if (fstatat(dirfd, leafname, &ent_stat,
+ AT_SYMLINK_NOFOLLOW) != 0) {
goto out_via_errno;
}
if (S_ISDIR(ent_stat.st_mode)) {
+ char *leafpath = NULL;
+
+ ret = netsurf_mkpath(&leafpath, NULL, 2, path,
leafname);
+ if (ret != NSERROR_OK)
+ goto out;
+
ret = netsurf_recursive_rm(leafpath);
- if (ret != NSERROR_OK) goto out;
+ free(leafpath);
+ if (ret != NSERROR_OK)
+ goto out;
} else {
- if (unlink(leafpath) != 0) {
+ if (unlinkat(dirfd, leafname, 0) != 0) {
goto out_via_errno;
}
}
- free(leafpath);
- leafpath = NULL;
}
if (rmdir(path) != 0) {
@@ -380,9 +397,7 @@ out:
free(listing);
}
- if (leafpath != NULL) {
- free(leafpath);
- }
+ close(dirfd);
return ret;
}
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=5fed462e88c8ec7ec25a668afa5b3f4b94eea4bb
commit 5fed462e88c8ec7ec25a668afa5b3f4b94eea4bb
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
urldb: Handle snprintf error
diff --git a/content/urldb.c b/content/urldb.c
index 74d0b7d..7352d67 100644
--- a/content/urldb.c
+++ b/content/urldb.c
@@ -1526,7 +1526,10 @@ static void urldb_dump_search(struct search_node
*parent, int depth)
for (h = parent->data; h; h = h->parent) {
if (h->part) {
r = snprintf(&s[i], sl - i, "%s", h->part);
- if ((i + r) > sl) {
+ if (r < 0) {
+ break;
+ }
+ if ((i + r) >= sl) {
break;
}
i += r;
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=836b5b61267e23872f6ce04ed6766c14ecebdf9e
commit 836b5b61267e23872f6ce04ed6766c14ecebdf9e
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
gtk: toolbar: Handle snprintf error
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index be676e2..6ec41cc 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -673,15 +673,22 @@ nsgtk_toolbar_customisation_save(struct nsgtk_toolbar *tb)
for (location = BACK_BUTTON;
location < PLACEHOLDER_BUTTON;
location++) {
+ int written;
itemid = itemid_from_location(tb, location);
if (itemid == PLACEHOLDER_BUTTON) {
/* no more filled locations */
break;
}
- start += snprintf(start,
+ written = snprintf(start,
orderlen - (start - order),
"%s/",
tb->items[itemid].name);
+ if ((written < 0) ||
+ (written >= orderlen - (start - order))) {
+ free(order);
+ return NSERROR_UNKNOWN;
+ }
+ start += written;
if ((start - order) >= orderlen) {
break;
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=a584c6bb3bc529043e26faed01b61cf56a39d4a7
commit a584c6bb3bc529043e26faed01b61cf56a39d4a7
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
gtk: pixbuf creation: Avoid int overflow before size_t conversion
diff --git a/frontends/gtk/gdk.c b/frontends/gtk/gdk.c
index 2912862..fe9a079 100644
--- a/frontends/gtk/gdk.c
+++ b/frontends/gtk/gdk.c
@@ -73,7 +73,7 @@ nsgdk_pixbuf_get_from_surface(cairo_surface_t *surface, int
scwidth, int scheigh
memset(gdk_pixbuf_get_pixels(pixbuf),
0xff,
- gdk_pixbuf_get_rowstride(pixbuf) * scheight);
+ gdk_pixbuf_get_rowstride(pixbuf) * (size_t)scheight);
/* scale cairo surface into new surface the target size */
cairo_surface_flush(surface); /* ensure source surface is ready */
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=743817c205be630cb46e4a2cef4da802b1f9084a
commit 743817c205be630cb46e4a2cef4da802b1f9084a
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
js: console: Fix argument type for formatting function
diff --git a/content/handlers/javascript/duktape/Console.bnd
b/content/handlers/javascript/duktape/Console.bnd
index 74601d6..89d13cf 100644
--- a/content/handlers/javascript/duktape/Console.bnd
+++ b/content/handlers/javascript/duktape/Console.bnd
@@ -182,7 +182,7 @@ method Console::timeEnd()
duk_del_prop(ctx, 0);
duk_push_string(ctx, "Timer elapsed: ");
duk_insert(ctx, 0);
- duk_push_sprintf(ctx, "%lu ms", (duk_uint_t)(time_ms - old_time_ms));
+ duk_push_sprintf(ctx, "%u ms", (duk_uint_t)(time_ms - old_time_ms));
write_log_entry(ctx, priv->group, BW_CS_FLAG_LEVEL_INFO);
return 0;
%}
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=cb5d63768c57a9428f961d340b1ff86a3289d581
commit cb5d63768c57a9428f961d340b1ff86a3289d581
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
js: image data: Avoid int overflow before size_t conversion
diff --git a/content/handlers/javascript/duktape/ImageData.bnd
b/content/handlers/javascript/duktape/ImageData.bnd
index 17673d9..be28cbd 100644
--- a/content/handlers/javascript/duktape/ImageData.bnd
+++ b/content/handlers/javascript/duktape/ImageData.bnd
@@ -39,6 +39,6 @@ getter ImageData::data()
%{
duk_push_this(ctx);
duk_get_prop_string(ctx, -1, MAGIC(DATA));
- duk_push_buffer_object(ctx, -1, 0, priv->width * priv->height * 4,
DUK_BUFOBJ_UINT8CLAMPEDARRAY);
+ duk_push_buffer_object(ctx, -1, 0, priv->width * priv->height * 4llu,
DUK_BUFOBJ_UINT8CLAMPEDARRAY);
return 1;
%}
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=c50f4bab09779bf5bbc191701128be3affd9a2dc
commit c50f4bab09779bf5bbc191701128be3affd9a2dc
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
Test: Add prefer_dark_mode to reference choices data
diff --git a/test/data/Choices-all b/test/data/Choices-all
index baae231..829a270 100644
--- a/test/data/Choices-all
+++ b/test/data/Choices-all
@@ -65,6 +65,7 @@ remove_backgrounds:0
enable_loosening:1
enable_PDF_compression:1
enable_PDF_password:0
+prefer_dark_mode:0
sys_colour_ActiveBorder:d3d3d3
sys_colour_ActiveCaption:f1f1f1
sys_colour_AppWorkspace:f1f1f1
-----------------------------------------------------------------------
Summary of changes:
.github/workflows/build.yaml | 104 +++++++++++++++++++++
.github/workflows/monkey-test.yaml | 62 ++++++++++++
.github/workflows/static-analysis.yaml | 58 ++++++++++++
content/handlers/image/image_cache.c | 2 +-
content/handlers/javascript/duktape/Console.bnd | 2 +-
content/handlers/javascript/duktape/ImageData.bnd | 2 +-
content/urldb.c | 5 +-
docs/env.sh | 27 +++++-
frontends/gtk/gdk.c | 2 +-
frontends/gtk/toolbar.c | 9 +-
test/data/Choices-all | 1 +
utils/file.c | 39 +++++---
utils/ssl_certs.c | 35 +++++--
13 files changed, 320 insertions(+), 28 deletions(-)
create mode 100644 .github/workflows/build.yaml
create mode 100644 .github/workflows/monkey-test.yaml
create mode 100644 .github/workflows/static-analysis.yaml
diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
new file mode 100644
index 0000000..69528c9
--- /dev/null
+++ b/.github/workflows/build.yaml
@@ -0,0 +1,104 @@
+name: "Linux Build"
+
+on: [push]
+
+jobs:
+ linux:
+ name: '${{ matrix.os }}: ${{ matrix.compiler.vendor }}'
+ runs-on: ${{ matrix.os }}
+ strategy:
+ fail-fast: false
+ matrix:
+ os:
+ - ubuntu-22.04
+ - ubuntu-20.04
+ compiler:
+ # The NetSurf build system can't find LLVM AR (it looks for it
+ # in /usr/lib instead of /usr/bin:
+ # `make: /usr/lib/llvm-ar: No such file or directory`).
+ # So we need to make it explicit for llvm.
+ - { vendor: gnu, CC: gcc }
+ - { vendor: llvm, CC: clang, AR: llvm-ar }
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v3
+ with:
+ fetch-depth: 1
+
+ - name: apt-get install packages
+ run: sudo apt-get update -qq &&
+ sudo apt-get install --no-install-recommends -y
+ bison
+ build-essential
+ check
+ clang
+ flex
+ git
+ gperf
+ libcurl4-openssl-dev
+ libgtk-3-dev
+ libhtml-parser-perl
+ libjpeg-dev
+ libpng-dev
+ librsvg2-dev
+ llvm
+ pkg-config
+ wbritish # Needed for `/usr/share/dict/words`, used by test
+
+ - name: Build and install project libs
+ env:
+ CC: ${{ matrix.compiler.CC }}
+ CXX: ${{ matrix.compiler.CXX }}
+ run: |
+ export TARGET_WORKSPACE="$(pwd)/projects"
+ source docs/env.sh
+ ns-clone -n -s
+ ns-make-tools install
+ ns-make-libs install
+
+ - name: Disable -Werror
+ # We can remove this step if we ever move to GitHub properly.
+ run: |
+ find . -type f -name Makefile | xargs sed -i 's/-Werror//'
+
+ - name: Unit Tests
+ # Fails when built with clang:
+ # test/corestrings.c:58:F:corestrings:corestrings_test:486:
+ # Assertion 'ires == NSERROR_NOMEM' failed: ires == 0, NSERROR_NOMEM ==
2
+ # Looks like `malloc_limit()` not working.
+ if: ${{ matrix.compiler.vendor != 'llvm' }}
+ env:
+ CC: ${{ matrix.compiler.CC }}
+ CXX: ${{ matrix.compiler.CXX }}
+ run: |
+ export TARGET_WORKSPACE="$(pwd)/projects"
+ source docs/env.sh
+ make test
+
+ - name: Build NetSurf GTK
+ env:
+ CC: ${{ matrix.compiler.CC }}
+ CXX: ${{ matrix.compiler.CXX }}
+ run: |
+ export TARGET_WORKSPACE="$(pwd)/projects"
+ source docs/env.sh
+ make -j"$(nproc)" TARGET=gtk
+
+ - name: Build NetSurf Monkey
+ env:
+ CC: ${{ matrix.compiler.CC }}
+ CXX: ${{ matrix.compiler.CXX }}
+ run: |
+ export TARGET_WORKSPACE="$(pwd)/projects"
+ source docs/env.sh
+ make -j"$(nproc)" TARGET=monkey
+
+ - name: Build NetSurf Framebuffer
+ env:
+ CC: ${{ matrix.compiler.CC }}
+ CXX: ${{ matrix.compiler.CXX }}
+ run: |
+ export TARGET_WORKSPACE="$(pwd)/projects"
+ source docs/env.sh
+ make -j"$(nproc)" TARGET=framebuffer
diff --git a/.github/workflows/monkey-test.yaml
b/.github/workflows/monkey-test.yaml
new file mode 100644
index 0000000..5f93e35
--- /dev/null
+++ b/.github/workflows/monkey-test.yaml
@@ -0,0 +1,62 @@
+name: "Monkey Test"
+
+on: [pull_request]
+
+jobs:
+ test:
+ name: '${{ matrix.test }}'
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ test:
+ - short-internet
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v3
+ with:
+ fetch-depth: 1
+
+ - name: apt-get install packages
+ run: sudo apt-get update -qq &&
+ sudo apt-get install --no-install-recommends -y
+ bison
+ build-essential
+ check
+ clang
+ flex
+ git
+ gperf
+ libcurl4-openssl-dev
+ libgtk-3-dev
+ libhtml-parser-perl
+ libjpeg-dev
+ libpng-dev
+ librsvg2-dev
+ llvm
+ pkg-config
+ wbritish # Needed for `/usr/share/dict/words`, used by test
+
+ - name: Build and install project libs
+ run: |
+ export TARGET_WORKSPACE="$(pwd)/projects"
+ source docs/env.sh
+ ns-clone -n -s
+ ns-make-tools install
+ ns-make-libs install
+
+ - name: Disable -Werror
+ # We can remove this step if we ever move to GitHub properly.
+ run: |
+ find . -type f -name Makefile | xargs sed -i 's/-Werror//'
+
+ - name: Build NetSurf Monkey
+ run: |
+ export TARGET_WORKSPACE="$(pwd)/projects"
+ source docs/env.sh
+ make -j"$(nproc)" TARGET=monkey
+
+ - name: Run Monkey Test
+ run: |
+ LC_ALL=C.UTF-8 test/monkey-see-monkey-do -v -d ${{ matrix.test }}
diff --git a/.github/workflows/static-analysis.yaml
b/.github/workflows/static-analysis.yaml
new file mode 100644
index 0000000..3f92548
--- /dev/null
+++ b/.github/workflows/static-analysis.yaml
@@ -0,0 +1,58 @@
+name: "Static Analysis"
+
+on: [push]
+
+jobs:
+ codeql:
+ name: Analyze with CodeQL
+ runs-on: ubuntu-22.04
+
+ strategy:
+ fail-fast: false
+ matrix:
+ language: ['cpp']
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v2
+ with:
+ fetch-depth: 1
+
+ - name: apt-get install packages
+ run: sudo apt-get update -qq &&
+ sudo apt-get install --no-install-recommends -y
+ bison
+ build-essential
+ flex
+ git
+ gperf
+ libcurl4-openssl-dev
+ libgtk-3-dev
+ libhtml-parser-perl
+ libjpeg-dev
+ libpng-dev
+ librsvg2-dev
+ pkg-config
+
+ - name: Build and install project libs
+ run: |
+ export TARGET_WORKSPACE="$(pwd)/projects"
+ source docs/env.sh
+ ns-clone -n -s
+ ns-make-tools install
+ ns-make-libs install
+
+ # Initializes the CodeQL tools for scanning.
+ - name: Initialize CodeQL
+ uses: github/codeql-action/init@v2
+ with:
+ languages: ${{ matrix.language }}
+
+ - name: Build NetSurf
+ run: |
+ export TARGET_WORKSPACE="$(pwd)/projects"
+ source docs/env.sh
+ make -j"$(nproc)"
+
+ - name: Perform CodeQL Analysis
+ uses: github/codeql-action/analyze@v2
diff --git a/content/handlers/image/image_cache.c
b/content/handlers/image/image_cache.c
index ae53192..8f7ff89 100644
--- a/content/handlers/image/image_cache.c
+++ b/content/handlers/image/image_cache.c
@@ -528,7 +528,7 @@ nserror image_cache_add(struct content *content,
image_cache__link(centry);
centry->content = content;
- centry->bitmap_size = content->width * content->height * 4;
+ centry->bitmap_size = content->width * content->height * 4llu;
}
NSLOG(netsurf, INFO, "centry %p, content %p, bitmap %p", centry,
diff --git a/content/handlers/javascript/duktape/Console.bnd
b/content/handlers/javascript/duktape/Console.bnd
index 74601d6..89d13cf 100644
--- a/content/handlers/javascript/duktape/Console.bnd
+++ b/content/handlers/javascript/duktape/Console.bnd
@@ -182,7 +182,7 @@ method Console::timeEnd()
duk_del_prop(ctx, 0);
duk_push_string(ctx, "Timer elapsed: ");
duk_insert(ctx, 0);
- duk_push_sprintf(ctx, "%lu ms", (duk_uint_t)(time_ms - old_time_ms));
+ duk_push_sprintf(ctx, "%u ms", (duk_uint_t)(time_ms - old_time_ms));
write_log_entry(ctx, priv->group, BW_CS_FLAG_LEVEL_INFO);
return 0;
%}
diff --git a/content/handlers/javascript/duktape/ImageData.bnd
b/content/handlers/javascript/duktape/ImageData.bnd
index 17673d9..be28cbd 100644
--- a/content/handlers/javascript/duktape/ImageData.bnd
+++ b/content/handlers/javascript/duktape/ImageData.bnd
@@ -39,6 +39,6 @@ getter ImageData::data()
%{
duk_push_this(ctx);
duk_get_prop_string(ctx, -1, MAGIC(DATA));
- duk_push_buffer_object(ctx, -1, 0, priv->width * priv->height * 4,
DUK_BUFOBJ_UINT8CLAMPEDARRAY);
+ duk_push_buffer_object(ctx, -1, 0, priv->width * priv->height * 4llu,
DUK_BUFOBJ_UINT8CLAMPEDARRAY);
return 1;
%}
diff --git a/content/urldb.c b/content/urldb.c
index 74d0b7d..7352d67 100644
--- a/content/urldb.c
+++ b/content/urldb.c
@@ -1526,7 +1526,10 @@ static void urldb_dump_search(struct search_node
*parent, int depth)
for (h = parent->data; h; h = h->parent) {
if (h->part) {
r = snprintf(&s[i], sl - i, "%s", h->part);
- if ((i + r) > sl) {
+ if (r < 0) {
+ break;
+ }
+ if ((i + r) >= sl) {
break;
}
i += r;
diff --git a/docs/env.sh b/docs/env.sh
index 80292a4..a9e52a3 100644
--- a/docs/env.sh
+++ b/docs/env.sh
@@ -344,19 +344,40 @@ ns-pull()
# clone all repositories
ns-clone()
{
+ SHALLOW=""
+ while [ $# -gt 0 ]
+ do
+ case "$1" in
+ -n | --not-netsurf) NS_BROWSER=
+ shift
+ ;;
+ -s | --shallow) SHALLOW="--depth 1"
+ shift
+ ;;
+ -*) echo "Error: Unknown option: $1" >&2
+ exit 1
+ ;;
+ *) # No more options
+ break
+ ;;
+ esac
+ done
+
mkdir -p ${TARGET_WORKSPACE}
for REPO in $(echo ${NS_BUILDSYSTEM} ${NS_INTERNAL_LIBS}
${NS_FRONTEND_LIBS} ${NS_RISCOS_LIBS} ${NS_TOOLS} ${NS_BROWSER}) ; do
echo -n " GIT: Cloning ${REPO}: "
if [ -f ${TARGET_WORKSPACE}/${REPO}/.git/config ]; then
echo "Repository already present"
else
- (cd ${TARGET_WORKSPACE} && git clone ${NS_GIT}/${REPO}.git; )
+ (cd ${TARGET_WORKSPACE} && git clone ${SHALLOW}
${NS_GIT}/${REPO}.git; )
fi
done
# put current env.sh in place in workspace
- if [ ! -f "${TARGET_WORKSPACE}/env.sh" -a -f
${TARGET_WORKSPACE}/${NS_BROWSER}/docs/env.sh ]; then
- cp ${TARGET_WORKSPACE}/${NS_BROWSER}/docs/env.sh
${TARGET_WORKSPACE}/env.sh
+ if [ "x$NS_BROWSER" = "x" ]; then
+ if [ ! -f "${TARGET_WORKSPACE}/env.sh" -a -f
${TARGET_WORKSPACE}/${NS_BROWSER}/docs/env.sh ]; then
+ cp ${TARGET_WORKSPACE}/${NS_BROWSER}/docs/env.sh
${TARGET_WORKSPACE}/env.sh
+ fi
fi
}
diff --git a/frontends/gtk/gdk.c b/frontends/gtk/gdk.c
index 2912862..fe9a079 100644
--- a/frontends/gtk/gdk.c
+++ b/frontends/gtk/gdk.c
@@ -73,7 +73,7 @@ nsgdk_pixbuf_get_from_surface(cairo_surface_t *surface, int
scwidth, int scheigh
memset(gdk_pixbuf_get_pixels(pixbuf),
0xff,
- gdk_pixbuf_get_rowstride(pixbuf) * scheight);
+ gdk_pixbuf_get_rowstride(pixbuf) * (size_t)scheight);
/* scale cairo surface into new surface the target size */
cairo_surface_flush(surface); /* ensure source surface is ready */
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index be676e2..6ec41cc 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -673,15 +673,22 @@ nsgtk_toolbar_customisation_save(struct nsgtk_toolbar *tb)
for (location = BACK_BUTTON;
location < PLACEHOLDER_BUTTON;
location++) {
+ int written;
itemid = itemid_from_location(tb, location);
if (itemid == PLACEHOLDER_BUTTON) {
/* no more filled locations */
break;
}
- start += snprintf(start,
+ written = snprintf(start,
orderlen - (start - order),
"%s/",
tb->items[itemid].name);
+ if ((written < 0) ||
+ (written >= orderlen - (start - order))) {
+ free(order);
+ return NSERROR_UNKNOWN;
+ }
+ start += written;
if ((start - order) >= orderlen) {
break;
diff --git a/test/data/Choices-all b/test/data/Choices-all
index baae231..829a270 100644
--- a/test/data/Choices-all
+++ b/test/data/Choices-all
@@ -65,6 +65,7 @@ remove_backgrounds:0
enable_loosening:1
enable_PDF_compression:1
enable_PDF_password:0
+prefer_dark_mode:0
sys_colour_ActiveBorder:d3d3d3
sys_colour_ActiveCaption:f1f1f1
sys_colour_AppWorkspace:f1f1f1
diff --git a/utils/file.c b/utils/file.c
index c460e49..3cf12d5 100644
--- a/utils/file.c
+++ b/utils/file.c
@@ -26,6 +26,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
+#include <fcntl.h>
#include <errno.h>
#include "desktop/gui_internal.h"
@@ -322,12 +323,23 @@ netsurf_recursive_rm(const char *path)
int nentries, ent;
nserror ret = NSERROR_OK;
struct stat ent_stat; /* stat result of leaf entry */
- char *leafpath = NULL;
const char *leafname;
+ int dirfd;
- nentries = scandir(path, &listing, 0, alphasort);
+ dirfd = open(path, O_DIRECTORY);
+ if (dirfd == -1) {
+ switch (errno) {
+ case ENOENT:
+ return NSERROR_NOT_FOUND;
+ default:
+ return NSERROR_UNKNOWN;
+ }
+ }
+ nentries = scandir(path, &listing, 0, alphasort);
if (nentries < 0) {
+ close(dirfd);
+
switch (errno) {
case ENOENT:
return NSERROR_NOT_FOUND;
@@ -341,21 +353,26 @@ netsurf_recursive_rm(const char *path)
if (strcmp(leafname, ".") == 0 ||
strcmp(leafname, "..") == 0)
continue;
- ret = netsurf_mkpath(&leafpath, NULL, 2, path, leafname);
- if (ret != NSERROR_OK) goto out;
- if (stat(leafpath, &ent_stat) != 0) {
+ if (fstatat(dirfd, leafname, &ent_stat,
+ AT_SYMLINK_NOFOLLOW) != 0) {
goto out_via_errno;
}
if (S_ISDIR(ent_stat.st_mode)) {
+ char *leafpath = NULL;
+
+ ret = netsurf_mkpath(&leafpath, NULL, 2, path,
leafname);
+ if (ret != NSERROR_OK)
+ goto out;
+
ret = netsurf_recursive_rm(leafpath);
- if (ret != NSERROR_OK) goto out;
+ free(leafpath);
+ if (ret != NSERROR_OK)
+ goto out;
} else {
- if (unlink(leafpath) != 0) {
+ if (unlinkat(dirfd, leafname, 0) != 0) {
goto out_via_errno;
}
}
- free(leafpath);
- leafpath = NULL;
}
if (rmdir(path) != 0) {
@@ -380,9 +397,7 @@ out:
free(listing);
}
- if (leafpath != NULL) {
- free(leafpath);
- }
+ close(dirfd);
return ret;
}
diff --git a/utils/ssl_certs.c b/utils/ssl_certs.c
index d0f2a6c..8546165 100644
--- a/utils/ssl_certs.c
+++ b/utils/ssl_certs.c
@@ -248,12 +248,23 @@ nserror cert_chain_to_query(struct cert_chain *chain,
struct nsurl **url_out )
urlstrlen = snprintf((char *)urlstr, allocsize, "about:certificate");
for (depth = 0; depth < chain->depth; depth++) {
+ int written;
nsuerror nsures;
size_t output_length;
- urlstrlen += snprintf((char *)urlstr + urlstrlen,
- allocsize - urlstrlen,
- "&cert=");
+ written = snprintf((char *)urlstr + urlstrlen,
+ allocsize - urlstrlen,
+ "&cert=");
+ if (written < 0) {
+ free(urlstr);
+ return NSERROR_UNKNOWN;
+ }
+ if ((size_t)written >= allocsize - urlstrlen) {
+ free(urlstr);
+ return NSERROR_UNKNOWN;
+ }
+
+ urlstrlen += (size_t)written;
output_length = allocsize - urlstrlen;
nsures = nsu_base64_encode_url(
@@ -268,10 +279,20 @@ nserror cert_chain_to_query(struct cert_chain *chain,
struct nsurl **url_out )
urlstrlen += output_length;
if (chain->certs[depth].err != SSL_CERT_ERR_OK) {
- urlstrlen += snprintf((char *)urlstr + urlstrlen,
- allocsize - urlstrlen,
- "&certerr=%d",
- chain->certs[depth].err);
+ written = snprintf((char *)urlstr + urlstrlen,
+ allocsize - urlstrlen,
+ "&certerr=%d",
+ chain->certs[depth].err);
+ if (written < 0) {
+ free(urlstr);
+ return NSERROR_UNKNOWN;
+ }
+ if ((size_t)written >= allocsize - urlstrlen) {
+ free(urlstr);
+ return NSERROR_UNKNOWN;
+ }
+
+ urlstrlen += (size_t)written;
}
}
--
NetSurf Browser
_______________________________________________
netsurf-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]