aboutsummaryrefslogtreecommitdiffstats
path: root/testing/tinyssh/keepalive-not-implemented.patch
blob: 19c21c1c23fc58b8f9b44b83c95519d342498ef6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
diff --git a/tinyssh-tests/packet_uinmplementedtest.c b/tinyssh-tests/packet_uinmplementedtest.c
new file mode 120000
index 0000000..c1c5f9b
--- /dev/null
+++ b/tinyssh-tests/packet_uinmplementedtest.c
@@ -0,0 +1 @@
+emptytest.c
\ No newline at end of file
diff --git a/tinyssh/LIBS b/tinyssh/LIBS
index 7f1bcf5..9c1f27a 100644
--- a/tinyssh/LIBS
+++ b/tinyssh/LIBS
@@ -36,6 +36,7 @@ packetparser.o
 packet_put.o
 packet_recv.o
 packet_send.o
+packet_uinmplemented.o
 porttostr.o
 randommod.o
 readall.o
diff --git a/tinyssh/SOURCES b/tinyssh/SOURCES
index be77a5f..613535d 100644
--- a/tinyssh/SOURCES
+++ b/tinyssh/SOURCES
@@ -36,6 +36,7 @@ packetparser
 packet_put
 packet_recv
 packet_send
+packet_uinmplemented
 porttostr
 randommod
 readall
diff --git a/tinyssh/packet.h b/tinyssh/packet.h
index 891ede8..b2cba92 100644
--- a/tinyssh/packet.h
+++ b/tinyssh/packet.h
@@ -127,4 +127,7 @@ extern int packet_channel_send_windowadjust(struct buf *);
 extern void packet_channel_send_eof(struct buf *);
 extern int packet_channel_send_close(struct buf *, int, int);
 
+/* packet_uinmplemented.c */
+extern int packet_uinmplemented(struct buf *);
+
 #endif
diff --git a/tinyssh/packet_uinmplemented.c b/tinyssh/packet_uinmplemented.c
new file mode 100644
index 0000000..1ca82d6
--- /dev/null
+++ b/tinyssh/packet_uinmplemented.c
@@ -0,0 +1,18 @@
+/*
+20150719
+Jan Mojzis
+Public domain.
+*/
+
+#include "buf.h"
+#include "ssh.h"
+#include "packet.h"
+
+int packet_uinmplemented(struct buf *b) {
+
+    buf_purge(b);
+    buf_putnum8(b, SSH_MSG_UNIMPLEMENTED);       /* SSH_MSG_UNIMPLEMENTED */
+    buf_putnum32(b, packet.receivepacketid);     /* packeid */
+    packet_put(b);
+    return packet_sendall();
+}
diff --git a/tinyssh/tinysshd.c b/tinyssh/tinysshd.c
index ba44584..78677f5 100644
--- a/tinyssh/tinysshd.c
+++ b/tinyssh/tinysshd.c
@@ -300,8 +300,8 @@ int main(int argc, char **argv) {
                 case SSH_MSG_KEXINIT:
                     goto rekeying;
                 default:
-                    die_fatal("unknown message type", 0, 0);
-                    /* XXX TODO - send SSH_MSG_UNIMPLEMENTED */
+                    log_d1("unknown packet - sending SSH_MSG_UNIMPLEMENTED message");
+                    if (!packet_uinmplemented(&b1)) die_fatal("unable to send SSH_MSG_UNIMPLEMENTED message", 0, 0);
             }
         }
     }