comparison cli-session.c @ 1741:d1b279aa5ed1 fuzz

Get client fuzzer building and starting (fails straight away)
author Matt Johnston <matt@ucc.asn.au>
date Sun, 18 Oct 2020 12:17:39 +0800
parents 83d48276885b
children 6e71440b1e47
comparison
equal deleted inserted replaced
1740:dfbe947bdf0d 1741:d1b279aa5ed1
405 static void recv_msg_global_request_cli(void) { 405 static void recv_msg_global_request_cli(void) {
406 TRACE(("recv_msg_global_request_cli")) 406 TRACE(("recv_msg_global_request_cli"))
407 /* Send a proper rejection */ 407 /* Send a proper rejection */
408 send_msg_request_failure(); 408 send_msg_request_failure();
409 } 409 }
410
411 void cli_dropbear_exit(int exitcode, const char* format, va_list param) {
412 char exitmsg[150];
413 char fullmsg[300];
414
415 /* Note that exit message must be rendered before session cleanup */
416
417 /* Render the formatted exit message */
418 vsnprintf(exitmsg, sizeof(exitmsg), format, param);
419 TRACE(("Exited, cleaning up: %s", exitmsg))
420
421 /* Add the prefix depending on session/auth state */
422 if (!ses.init_done) {
423 snprintf(fullmsg, sizeof(fullmsg), "Exited: %s", exitmsg);
424 } else {
425 snprintf(fullmsg, sizeof(fullmsg),
426 "Connection to %s@%s:%s exited: %s",
427 cli_opts.username, cli_opts.remotehost,
428 cli_opts.remoteport, exitmsg);
429 }
430
431 /* Do the cleanup first, since then the terminal will be reset */
432 session_cleanup();
433 /* Avoid printing onwards from terminal cruft */
434 fprintf(stderr, "\n");
435
436 dropbear_log(LOG_INFO, "%s", fullmsg);
437
438 #if DROPBEAR_FUZZ
439 if (fuzz.do_jmp) {
440 longjmp(fuzz.jmp, 1);
441 }
442 #endif
443
444 exit(exitcode);
445 }
446
447 void cli_dropbear_log(int priority, const char* format, va_list param) {
448
449 char printbuf[1024];
450 const char *name;
451
452 name = cli_opts.progname;
453 if (!name) {
454 name = "dbclient";
455 }
456
457 vsnprintf(printbuf, sizeof(printbuf), format, param);
458
459 #ifndef DISABLE_SYSLOG
460 if (opts.usingsyslog) {
461 syslog(priority, "%s", printbuf);
462 }
463 #endif
464
465 fprintf(stderr, "%s: %s\n", name, printbuf);
466 fflush(stderr);
467 }
468