Skip to content
This repository was archived by the owner on Sep 24, 2020. It is now read-only.

Commit 477c010

Browse files
committed
fixed repeatition of past values
1 parent 120fa5e commit 477c010

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

bin/client

-41.9 KB
Binary file not shown.

bin/server

-37.7 KB
Binary file not shown.

pkg/handlers/echo.c

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ void EchoProtocolSendRequestToServer(int socket) {
44
char input[MAX_BUFFER];
55
fgets(input, MAX_BUFFER - 1, stdin);
66
char *arr_ptr = &input[0];
7+
arr_ptr[strlen(arr_ptr) - 1] = '\0';
8+
79
char *request = malloc(strlen(arr_ptr) + PROTOCOL_HEADER_LEN);
810
int mesg_length = MarshallMessage(request, 0xC0DE, ECHO_REQUEST, input);
911
Message message;

pkg/handlers/list_directory.c

+8-1
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,14 @@ void ListDirectoryProtocolServerHandler(int socket, Message message) {
3939
// present.
4040
while ((ent = readdir(dir)) != NULL) {
4141
char temp[256];
42+
memset(temp,0,256);
4243

4344
// Prints all of the data to the console.
4445
sscanf(ent->d_name, "%s\n",
4546
temp); // Trimming on both sides occurs here
4647
strcat(payload, temp);
4748
strcat(payload, " | ");
49+
4850
}
4951
closedir(dir);
5052
}
@@ -65,6 +67,11 @@ void ListDirectoryProtocolServerHandler(int socket, Message message) {
6567
int mesg_length = MarshallMessage(reply, 0xC0DE, protocol, arr_ptr);
6668
if (send(socket, reply, strlen(arr_ptr) + PROTOCOL_HEADER_LEN, 0) == -1)
6769
perror("write failed: ");
70+
memset(reply, 0, sizeof(reply));
71+
memset(arr_ptr, 0, sizeof(arr_ptr));
72+
// memset(payload, 0, sizeof(payload));
73+
6874
fprintf(stderr,
69-
"[DEBUG] List Directory Handler Server : Replying kbac .... \n");
75+
"[DEBUG] List Directory Handler Server : Replying back .... \n");
76+
7077
}

0 commit comments

Comments
 (0)