[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[shepherd] 03/05: shepherd: Protect against unrecognized sexps.
From: |
Ludovic Courtès |
Subject: |
[shepherd] 03/05: shepherd: Protect against unrecognized sexps. |
Date: |
Sat, 23 Jan 2016 22:20:27 +0000 |
civodul pushed a commit to branch master
in repository shepherd.
commit eaaf421f736344e82ca0a5a812105a7db7f421fe
Author: Ludovic Courtès <address@hidden>
Date: Sat Jan 23 18:01:46 2016 +0100
shepherd: Protect against unrecognized sexps.
* modules/shepherd/comm.scm (read-command): Return #f for anything that
doesn't match the expected form.
* tests/misbehaved-client.sh: Add test.
---
modules/shepherd/comm.scm | 2 +-
tests/misbehaved-client.sh | 9 +++++++++
2 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/modules/shepherd/comm.scm b/modules/shepherd/comm.scm
index 4e89ee4..37c3796 100644
--- a/modules/shepherd/comm.scm
+++ b/modules/shepherd/comm.scm
@@ -101,7 +101,7 @@ wrong---premature end-of-file, invalid sexp, etc."
(shepherd-command action service
#:arguments args
#:directory directory))
- ((? eof-object? eof)
+ (_ ;EOF or unmatched sexp
#f)))
(lambda _
;; Invalid sexp.
diff --git a/tests/misbehaved-client.sh b/tests/misbehaved-client.sh
index 87d4505..4c21cab 100644
--- a/tests/misbehaved-client.sh
+++ b/tests/misbehaved-client.sh
@@ -58,6 +58,15 @@ $herd status # still here?
"$GUILE" -c "
(use-modules (shepherd comm))
+;; Send an unrecognized sexp.
+(let ((sock (open-connection \"$socket\")))
+ (display \"(hi there)\" sock))"
+
+$herd status # still here?
+
+"$GUILE" -c "
+(use-modules (shepherd comm))
+
(let ((sock (open-connection \"$socket\")))
(setvbuf sock _IOFBF 5000)
(write-command (shepherd-command 'status 'dmd) sock)