summaryrefslogtreecommitdiffstats
path: root/src/basic/hexdecoct.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2023-11-03 14:07:39 +0100
committerLennart Poettering <lennart@poettering.net>2023-11-03 21:35:24 +0100
commita5559e06227d1ae7356ae6ade7a23c4868d92c91 (patch)
tree15e05aa92038af1fd040bce16b28795ef85fdd45 /src/basic/hexdecoct.c
parentMerge pull request #29847 from dtardon/udevadm-control-arg-processing (diff)
downloadsystemd-a5559e06227d1ae7356ae6ade7a23c4868d92c91.tar.xz
systemd-a5559e06227d1ae7356ae6ade7a23c4868d92c91.zip
hexdecoct: implicitly parse URL-safe base64 format, too
JSON-I (RFC 7493) suggests to use the URL safe base64 alphabet, rather than the regular one when encoding binary data in JSON strings. We generally uses the regular alphabet though. Let's be tolerant in what we parse however: simply accept both formats when we parse base64. This does nothing about base64 generation though, only about parsing.
Diffstat (limited to '')
-rw-r--r--src/basic/hexdecoct.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/basic/hexdecoct.c b/src/basic/hexdecoct.c
index 898ed83f86..ea683eb427 100644
--- a/src/basic/hexdecoct.c
+++ b/src/basic/hexdecoct.c
@@ -553,12 +553,12 @@ int unbase64char(char c) {
offset += '9' - '0' + 1;
- if (c == '+')
+ if (IN_SET(c, '+', '-')) /* Support both the regular and the URL safe character set (see above) */
return offset;
offset++;
- if (c == '/')
+ if (IN_SET(c, '/', '_')) /* ditto */
return offset;
return -EINVAL;