Browse Source

Fix error message for illegal command

Serj Kalichev 5 months ago
parent
commit
4af6fd4660
2 changed files with 9 additions and 2 deletions
  1. 7 1
      klish/ktp/ktp_session.c
  2. 2 1
      klish/ktp/ktpd_session.c

+ 7 - 1
klish/ktp/ktp_session.c

@@ -421,8 +421,14 @@ static bool_t ktp_session_process_cmd_ack(ktp_session_t *ktp, const faux_msg_t *
 	// Server will not send retcode in a case of empty command. Empty command
 	// doesn't execute real actions
 	if (faux_msg_get_param_by_type(msg, KTP_PARAM_RETCODE,
-		(void **)&retcode8bit, NULL))
+		(void **)&retcode8bit, NULL)) {
 		ktp->cmd_retcode = (int)(*retcode8bit);
+	} else {
+		if (KTP_STATUS_IS_ERROR(status))
+			ktp->cmd_retcode = -1;
+		else
+			ktp->cmd_retcode = 0;
+	}
 	error_str = faux_msg_get_str_param_by_type(msg, KTP_PARAM_ERROR);
 	if (error_str) {
 		faux_error_add(ktp->error, error_str);

+ 2 - 1
klish/ktp/ktpd_session.c

@@ -356,7 +356,8 @@ static bool_t ktpd_session_process_cmd(ktpd_session_t *ktpd, faux_msg_t *msg)
 	assert(msg);
 
 	// Get line from message
-	if (!(line = faux_msg_get_str_param_by_type(msg, KTP_PARAM_LINE))) {
+	line = faux_msg_get_str_param_by_type(msg, KTP_PARAM_LINE);
+	if (faux_str_is_empty(line)) {
 		// Line is not specified. User sent empty command.
 		// It's not bug. Send OK to user and regenerate prompt
 		ack = ktp_msg_preform(cmd, KTP_STATUS_NONE);