summaryrefslogtreecommitdiff
path: root/src/journal
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-07-29 22:01:36 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-07-31 04:00:31 -0400
commita2a5291b3f5ab6ed4c92f51d0fd10a03047380d8 (patch)
tree1a74a85c70861b0a411d9dd325b039976de4fd4e /src/journal
parent73381fcf54e38456067f0e87b8611a21eff99169 (diff)
Reject invalid quoted strings
String which ended in an unfinished quote were accepted, potentially with bad memory accesses. Reject anything which ends in a unfished quote, or contains non-whitespace characters right after the closing quote. _FOREACH_WORD now returns the invalid character in *state. But this return value is not checked anywhere yet. Also, make 'word' and 'state' variables const pointers, and rename 'w' to 'word' in various places. Things are easier to read if the same name is used consistently. mbiebl_> am I correct that something like this doesn't work mbiebl_> ExecStart=/usr/bin/encfs --extpass='/bin/systemd-ask-passwd "Unlock EncFS"' mbiebl_> systemd seems to strip of the quotes mbiebl_> systemctl status shows mbiebl_> ExecStart=/usr/bin/encfs --extpass='/bin/systemd-ask-password Unlock EncFS $RootDir $MountPoint mbiebl_> which is pretty weird
Diffstat (limited to 'src/journal')
-rw-r--r--src/journal/journald-server.c2
-rw-r--r--src/journal/sd-journal.c20
2 files changed, 11 insertions, 11 deletions
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
index 4ea9d43c0d..eac0a4ca67 100644
--- a/src/journal/journald-server.c
+++ b/src/journal/journald-server.c
@@ -1282,7 +1282,7 @@ static int setup_signals(Server *s) {
static int server_parse_proc_cmdline(Server *s) {
_cleanup_free_ char *line = NULL;
- char *w, *state;
+ const char *w, *state;
size_t l;
int r;
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
index 6349aeb785..01c91e4c02 100644
--- a/src/journal/sd-journal.c
+++ b/src/journal/sd-journal.c
@@ -997,7 +997,7 @@ _public_ int sd_journal_get_cursor(sd_journal *j, char **cursor) {
}
_public_ int sd_journal_seek_cursor(sd_journal *j, const char *cursor) {
- char *w, *state;
+ const char *word, *state;
size_t l;
unsigned long long seqnum, monotonic, realtime, xor_hash;
bool
@@ -1013,18 +1013,18 @@ _public_ int sd_journal_seek_cursor(sd_journal *j, const char *cursor) {
assert_return(!journal_pid_changed(j), -ECHILD);
assert_return(!isempty(cursor), -EINVAL);
- FOREACH_WORD_SEPARATOR(w, l, cursor, ";", state) {
+ FOREACH_WORD_SEPARATOR(word, l, cursor, ";", state) {
char *item;
int k = 0;
- if (l < 2 || w[1] != '=')
+ if (l < 2 || word[1] != '=')
return -EINVAL;
- item = strndup(w, l);
+ item = strndup(word, l);
if (!item)
return -ENOMEM;
- switch (w[0]) {
+ switch (word[0]) {
case 's':
seqnum_id_set = true;
@@ -1103,7 +1103,7 @@ _public_ int sd_journal_seek_cursor(sd_journal *j, const char *cursor) {
_public_ int sd_journal_test_cursor(sd_journal *j, const char *cursor) {
int r;
- char *w, *state;
+ const char *word, *state;
size_t l;
Object *o;
@@ -1118,20 +1118,20 @@ _public_ int sd_journal_test_cursor(sd_journal *j, const char *cursor) {
if (r < 0)
return r;
- FOREACH_WORD_SEPARATOR(w, l, cursor, ";", state) {
+ FOREACH_WORD_SEPARATOR(word, l, cursor, ";", state) {
_cleanup_free_ char *item = NULL;
sd_id128_t id;
unsigned long long ll;
int k = 0;
- if (l < 2 || w[1] != '=')
+ if (l < 2 || word[1] != '=')
return -EINVAL;
- item = strndup(w, l);
+ item = strndup(word, l);
if (!item)
return -ENOMEM;
- switch (w[0]) {
+ switch (word[0]) {
case 's':
k = sd_id128_from_string(item+2, &id);