Commit Graph

983 Commits

Author SHA1 Message Date
Daniel Silverstone 758cafe405
idna: Bounds check during encode/decode
Detected by some norwegian students who were doing security
analysis, we would overrun buffers in idna_{en,de}code() so
this corrects that problem.

Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2024-05-27 10:18:44 +01:00
Daniel Silverstone ea13f5a077
nsurl: Free host if nomem encountered
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2024-05-27 10:17:56 +01:00
Daniel Silverstone 6cbaf05ba3
nsurl: Correctly return non-IDNA hosts
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2024-05-27 10:17:31 +01:00
Daniel Silverstone 8193a5518e
utils: Add clamp() macro
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2024-05-27 09:35:49 +01:00
Daniel Silverstone 553dc93ec8
nsurl: Add support for IPv6 literals
Unfortunately, despite previous assertions to the contrary,
we do need to deal with IPv6 literals.  For now we validate
just that they are encased by square brackets and consist only
of hex digits and colons.  We do not validate that they are
actually valid IPv6 addresses.

Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2024-05-25 12:05:20 +01:00
Daniel Silverstone 1b10fcedcf
nsurl: Add underscore to permitted characters
The host component must be a valid DNS name; and unfortunately
underscores are present in some DNS names already, despite a 2019
decision to not issue them going forward.  As such we permit the
underscore as well in order to work with old-school URLs which may
exist in the wild.

Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2024-05-25 11:50:40 +01:00
Daniel Silverstone 4a50da326a nsurl: Reject URLs with invalid host components
The host component, by the time we hit the validation code, should
be a valid DNS name.  In theory it could also be an IPv6 address,
but those are far more painful to deal with so we're ignoring that
opportunity for now.

This fixes a problem where the search_web_omni logic would fail
to generate a search because nsurl_create() succeeded even though
it shouldn't have.

Signed-off-by: Daniel Silverstone <dsilvers@netsurf-browser.org>
2024-05-24 21:51:35 +01:00
Daniel Silverstone 74791c0229 utils: Belt and braces to satisfy gcc
GCC was upset that it was theoretically possible for this
format string to result in a buffer overrun.  This is because
it could not work out that `i` would never be negative. To
silence the warning, we use %u and cast to unsigned during the
formatting of the output filename.

Signed-off-by: Daniel Silverstone <dsilvers@netsurf-browser.org>
2024-05-24 19:44:40 +01:00
Daniel Silverstone 9e448ebfcd utils: Update config.h for confusing define problems
For some reason, we have to use the __GLIBC_PREREQ macro
in a more confined way otherwise the preprocessor gets confused.

Signed-off-by: Daniel Silverstone <dsilvers@netsurf-browser.org>
2024-05-24 19:32:34 +01:00
Daniel Silverstone 34239ed89f utils: Update guard checks in config.h
Since glibc 2.38 the functions strchrnul and strcasestr have been
exposed by default, rather than being hidden behind _GNU_SOURCE.

We therefore use the GLIBC_PREREQ macro to check the version of
the glibc headers and do not accidentally double-declare these
functions.

Signed-off-by: Daniel Silverstone <dsilvers@netsurf-browser.org>
2024-05-24 19:14:46 +01:00
John-Mark Bell cf2e5b5bc6 Socket: avoid warning on aos3 2024-03-14 00:05:51 +00:00
John-Mark Bell ae8b58e408 Socket: more fixes for win32/aos3
These special snowflakes have specialised socket close APIs, so
ensure that we use the correct one. Additionally, there's no
guarantee that their socket() API signature matches the POSIX
definition, so wrap it up and cast the result.
2024-03-14 00:01:24 +00:00
John-Mark Bell bda0a97fea Socket: fix win32/aos3 build 2024-03-13 23:22:31 +00:00
Vincent Sanders b5f4d905f9 use attributes to indicate switch fall through instead of comments 2024-03-05 21:33:13 +00:00
Vincent Sanders 7231217271 fix parameters on log function definitions 2024-02-27 12:31:08 +00:00
Vincent Sanders dbe5d1ef87 Implement simple jpeg xl image handler 2023-11-26 17:26:09 +00:00
Michael Drake c987b043b1 Clean up print format specifier usage 2023-06-17 11:20:09 +01:00
DeltaVonNeumann a16d5ff10b Avoid integer types with platform dependent size 2023-06-17 10:29:39 +01:00
John-Mark Bell b56d74b5df Retire long-dead code 2023-03-12 21:38:10 +00:00
Daniel Silverstone 764fca4f3a
utils/utf8.c: Fix missing format string for snprintf
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2022-11-26 16:55:47 +00:00
Vincent Sanders 0c25ae5e8e remove the ambiguity around the reallocation in utf8_to_html() 2022-11-26 15:21:16 +00:00
Vincent Sanders 1d82ef411a consolodate duplicated conversion descriptor cache code 2022-11-26 15:21:16 +00:00
Vincent Sanders 6780766fb7 Improve utf8 conversion function
Newer compilers were (correctly) pointing out use after free.

Slightly reworkeed conversion function to remove compiler warnings
and clean up implementation.
2022-11-26 15:21:16 +00:00
John-Mark Bell 0718e58681 utils: Use fstatat and unlinkat if supported 2022-11-02 17:28:18 +00:00
Michael Drake 1810fbfe22 Revert "utils: file: Use fstatat and unlinkat"
On may of the platforms we build for (RISC OS, Windows, Amiga OS4,
Amiga OS3, and Atari), this was causing:

- utils/file.c:329 error: 'O_DIRECTORY' undeclared
- utils/file.c:357 error: 'AT_SYMLINK_NOFOLLOW' undeclared

This reverts commit ef00567b02.
2022-11-02 13:35:11 +00:00
Michael Drake 15b23e1e3c log: Add flex logging catagory 2022-10-29 20:30:48 +01:00
Michael Drake 6c4343a742 utils: ssl_certs: Fix potential snprintf overflow 2022-10-23 17:22:56 +01:00
Michael Drake ef00567b02 utils: file: Use fstatat and unlinkat 2022-10-23 17:22:56 +01:00
John-Mark Bell 6f99d28488 UA: align with compat spec
See: https://compat.spec.whatwg.org/#ua-string-section

Force desktop sites on Linux by claiming to be running under X11
(Linux is otherwise considered a mobile OS).
2022-05-27 21:47:02 +01:00
Michael Drake 32d9de461e util: corestring: Add DOM "reversed" string. 2021-02-10 17:59:12 +00:00
Michael Drake 4c941254c8 util: corestring: Add DOM "start" string. 2021-02-10 17:08:23 +00:00
Vincent Sanders e34f1c8b33 ensure background fraction is a proper fraction 2020-06-29 08:50:39 +01:00
Vincent Sanders b47a897699 update idna properties to unicode 11 2020-06-27 23:30:54 +01:00
Vincent Sanders 421d796e9b split tools and utils 2020-06-27 23:30:54 +01:00
Vincent Sanders 1dab82d655 Improve user choices file processing
Improve the key/value processing in choices file.

Fixes several oddities discovered including:
 removing the last character of the last value.
 possible buffer overflow with certian values
2020-06-27 23:24:59 +01:00
Vincent Sanders 1acf3abb39 make the idna properties header building an explicit target 2020-06-25 09:32:27 +01:00
Vincent Sanders 567390f59d allow idna_props header to be regenerated
add commandline procesing to the idna header generation tool

add make rules to obtain idna source files and convert them into a header
2020-06-22 23:08:03 +01:00
Vincent Sanders 54e06e7d58 move all the build tools to utils
move the source and make rules of the convert image and font tools
 to the utils directory. This puts all the rules for build tools together.
2020-06-22 22:45:10 +01:00
Vincent Sanders b2a1aa9b88 improvements from review 2020-06-21 12:08:24 +01:00
Vincent Sanders f31fb08c73 add gzip compression support to c split-messages implementation 2020-06-15 09:06:25 +01:00
Vincent Sanders d5d14df76b initial implementation of split messages in c
functional but the compression switch still needs implementing
2020-06-15 00:21:06 +01:00
Vincent Sanders 154a6b6987 implement a minimal xxd for builds to remove external dependancy 2020-06-03 23:34:57 +01:00
Vincent Sanders 9071b450be update jenkins build script after 3.10 release 2020-05-25 08:57:09 +01:00
Daniel Silverstone 04e9e75b27
idna: Do not overcopy utf8 buffer as though it were ucs4
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2020-05-24 10:38:21 +01:00
Michael Drake 994827ab82 NS colour: Add colour scheme for text inputs. 2020-05-23 21:33:42 +01:00
Daniel Silverstone 4d927ff409
corestrings: Add a key for canvas node data
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2020-05-22 15:58:38 +01:00
Michael Drake 1347f9e3a6 nsurl: Expose scheme type accessor. 2020-05-19 21:01:09 +01:00
Vincent Sanders fbc0847db0 move ssl certificate serialisation into a url to the ssl_cert utility code 2020-05-09 22:42:12 +01:00
Michael Drake 9fa6ac7113 nscolour: Add function to get nscolour stylesheet. 2020-04-07 21:32:27 +01:00
Michael Drake 13e0faa261 Buildsystem: Build the nscolour module. 2020-04-07 21:32:27 +01:00