summaryrefslogtreecommitdiffhomepage
path: root/svr-runopts.c
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2017-05-12 23:14:54 +0800
committerMatt Johnston <matt@ucc.asn.au>2017-05-12 23:14:54 +0800
commit9f24cdf74c93aa75416687972e69b5b4c8be2698 (patch)
tree9de10a9cfb200ced849cce21005253e0b93b7711 /svr-runopts.c
parentd7471c4f875a2be9dde4e65d06f71bf7c68d5ff5 (diff)
copy over some fuzzing code from AFL branch
--HG-- branch : fuzz
Diffstat (limited to 'svr-runopts.c')
-rw-r--r--svr-runopts.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/svr-runopts.c b/svr-runopts.c
index 8f60059..c0b7bf2 100644
--- a/svr-runopts.c
+++ b/svr-runopts.c
@@ -346,6 +346,19 @@ void svr_getopts(int argc, char ** argv) {
}
opts.idle_timeout_secs = val;
}
+
+#ifdef DROPBEAR_FUZZ
+ if (opts.fuzz.fuzzing) {
+ struct passwd *pw;
+ /* user lookups might be slow, cache it */
+ pw = getpwuid(getuid());
+ dropbear_assert(pw);
+ opts.fuzz.pw_name = m_strdup(pw->pw_name);
+ opts.fuzz.pw_dir = m_strdup(pw->pw_dir);
+ opts.fuzz.pw_shell = m_strdup(pw->pw_shell);
+ opts.fuzz.pw_passwd = m_strdup("!!zzznope");
+ }
+#endif
}
static void addportandaddress(const char* spec) {
@@ -475,11 +488,57 @@ static void addhostkey(const char *keyfile) {
svr_opts.num_hostkey_files++;
}
+#ifdef DROPBEAR_FUZZ
+static void load_fixed_hostkeys() {
+#include "hostkeys.c"
+
+ buffer *b = buf_new(3000);
+ enum signkey_type type;
+
+ TRACE(("load fixed hostkeys"))
+
+ svr_opts.hostkey = new_sign_key();
+
+ buf_setlen(b, 0);
+ buf_putbytes(b, keyr, keyr_len);
+ buf_setpos(b, 0);
+ type = DROPBEAR_SIGNKEY_RSA;
+ if (buf_get_priv_key(b, svr_opts.hostkey, &type) == DROPBEAR_FAILURE) {
+ dropbear_exit("failed fixed rsa hostkey");
+ }
+
+ buf_setlen(b, 0);
+ buf_putbytes(b, keyd, keyd_len);
+ buf_setpos(b, 0);
+ type = DROPBEAR_SIGNKEY_DSS;
+ if (buf_get_priv_key(b, svr_opts.hostkey, &type) == DROPBEAR_FAILURE) {
+ dropbear_exit("failed fixed dss hostkey");
+ }
+
+ buf_setlen(b, 0);
+ buf_putbytes(b, keye, keye_len);
+ buf_setpos(b, 0);
+ type = DROPBEAR_SIGNKEY_ECDSA_NISTP256;
+ if (buf_get_priv_key(b, svr_opts.hostkey, &type) == DROPBEAR_FAILURE) {
+ dropbear_exit("failed fixed ecdsa hostkey");
+ }
+
+ buf_free(b);
+}
+#endif // DROPBEAR_FUZZ
+
void load_all_hostkeys() {
int i;
int disable_unset_keys = 1;
int any_keys = 0;
+#ifdef DROPBEAR_FUZZ
+ if (opts.fuzz.fuzzing) {
+ load_fixed_hostkeys();
+ return;
+ }
+#endif
+
svr_opts.hostkey = new_sign_key();
for (i = 0; i < svr_opts.num_hostkey_files; i++) {