Removing key has a pointer to be a fixed size.
This commit is contained in:
parent
e9983c77c2
commit
a6a4fbf7ac
12
src/server.c
12
src/server.c
@ -17,7 +17,7 @@
|
|||||||
typedef struct Request
|
typedef struct Request
|
||||||
{
|
{
|
||||||
unsigned char type;
|
unsigned char type;
|
||||||
char *key;
|
char key[256];
|
||||||
int ID;
|
int ID;
|
||||||
int level;
|
int level;
|
||||||
} Request;
|
} Request;
|
||||||
@ -61,13 +61,7 @@ int main(void)
|
|||||||
|
|
||||||
Request req;
|
Request req;
|
||||||
|
|
||||||
req.key = malloc(256 * sizeof(char));
|
memset(&req, 0, sizeof(req));
|
||||||
if (req.key == NULL)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "Memory allocation failed\n");
|
|
||||||
close(sockfd);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
req.ID = 0;
|
req.ID = 0;
|
||||||
req.level = 0;
|
req.level = 0;
|
||||||
req.type = 0;
|
req.type = 0;
|
||||||
@ -120,7 +114,7 @@ int main(void)
|
|||||||
{
|
{
|
||||||
Request aux;
|
Request aux;
|
||||||
aux.ID = req.ID;
|
aux.ID = req.ID;
|
||||||
aux.key = NULL;
|
memset(&req, 0, sizeof(req));
|
||||||
aux.type = req.type;
|
aux.type = req.type;
|
||||||
aux.level = -1;
|
aux.level = -1;
|
||||||
send(connfd, &aux, sizeof(aux), 0);
|
send(connfd, &aux, sizeof(aux), 0);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user