Commit da395009 authored by Takeshi Yoshimura's avatar Takeshi Yoshimura Committed by Jim Harris
Browse files

framework: fix null deref if no tty



Change-Id: I859a390e830d43e921244a8a482a63e5c8afe56c
Signed-off-by: default avatarTakeshi Yoshimura <tyos@jp.ibm.com>
Reviewed-on: https://review.gerrithub.io/424016


Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 33ccbba4
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -546,6 +546,7 @@ spdk_app_start(struct spdk_app_opts *opts, spdk_event_fn start_fn,
	struct spdk_conf	*config = NULL;
	int			rc;
	struct spdk_event	*rpc_start_event;
	char			*tty;

	if (!opts) {
		SPDK_ERRLOG("opts should not be NULL\n");
@@ -557,9 +558,11 @@ spdk_app_start(struct spdk_app_opts *opts, spdk_event_fn start_fn,
		return 1;
	}

	tty = ttyname(STDERR_FILENO);
	if (opts->print_level > SPDK_LOG_WARN &&
	    isatty(STDERR_FILENO) &&
	    !strncmp(ttyname(STDERR_FILENO), "/dev/tty", strlen("/dev/tty"))) {
	    tty &&
	    !strncmp(tty, "/dev/tty", strlen("/dev/tty"))) {
		printf("Warning: printing stderr to console terminal without -q option specified.\n");
		printf("Suggest using --silence-noticelog to disable logging to stderr and\n");
		printf("monitor syslog, or redirect stderr to a file.\n");