diff --git a/src/cli.c b/src/cli.c index 892b174..45f63b3 100644 --- a/src/cli.c +++ b/src/cli.c @@ -86,7 +86,7 @@ void connectedCommunication(int sockfd) char sendBuff[SEND_BUFFER_SIZE] = {0}; char receiveBuff[RECEIVE_BUFFER_SIZE] = {0}; - char historyBuff[SEND_BUFFER_SIZE * NHISTORY] = {0}; + char historyBuff[SEND_BUFFER_SIZE * NHISTORY + 1] = {0}; int historyIndex = 0, historyModifier; char curChar; @@ -136,7 +136,7 @@ void connectedCommunication(int sockfd) if (historyIndex <= 0) break; historyModifier = (historyModifier + 1) - % (historyIndex); + % (historyIndex + 1); printf("\33[2K\r%s%s", promptString, &historyBuff[ @@ -155,8 +155,8 @@ void connectedCommunication(int sockfd) if (historyIndex <= 0) break; - historyModifier = (historyModifier + historyIndex - 1) - % (historyIndex); + historyModifier = (historyModifier + historyIndex) + % (historyIndex + 1); printf("\33[2K\r%s%s", promptString, &historyBuff[