From b5be7416179c0878818019c7f5f9e3824c44c2f4 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Thu, 8 Jul 2021 18:49:27 +0200 Subject: [PATCH] Invalid command! --- src/cli.c | 7 ++++++- src/server.c | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/cli.c b/src/cli.c index 22d97b0..503d79b 100644 --- a/src/cli.c +++ b/src/cli.c @@ -69,7 +69,12 @@ void connectedCommunication(int sockfd) // Reading server answer read(sockfd, receiveBuff, sizeof(receiveBuff)); - printf("%s\n", receiveBuff); + // Detect null-string returned + if (receiveBuff[0] == 0) { + printLog("An error occured or invalid command!"); + } + + printf("%s\n\n", receiveBuff); } } diff --git a/src/server.c b/src/server.c index 1bf7a71..58fc334 100644 --- a/src/server.c +++ b/src/server.c @@ -76,7 +76,7 @@ static void serverCommunicationInstance(Server_t *args, int sockfd) } // Zeroing buffer - snprintf(sendBuff, SEND_BUFFER_SIZE, "%s", "Invalid command!"); + bzero(sendBuff, RECEIVE_BUFFER_SIZE); // Execute command by first arg in cmdList for (int i = 0; i < LEN(cmdList); i++) {