mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-27 23:42:58 +02:00
luaclient: fix result buffer overflow
This commit is contained in:
@@ -76,7 +76,7 @@ int main(int argc, char** argv)
|
|||||||
int res = -1;
|
int res = -1;
|
||||||
const char *fun = NULL;
|
const char *fun = NULL;
|
||||||
char *resp = NULL;
|
char *resp = NULL;
|
||||||
char result[size];
|
char *result = NULL;
|
||||||
|
|
||||||
if (!client.Send(data, size)) {
|
if (!client.Send(data, size)) {
|
||||||
fun = "Send failed";
|
fun = "Send failed";
|
||||||
@@ -86,7 +86,10 @@ int main(int argc, char** argv)
|
|||||||
fun = "Recv (1) failed";
|
fun = "Recv (1) failed";
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
if (!client.Recv(result, size)) {
|
if(size)
|
||||||
|
result = (char*) malloc(size);
|
||||||
|
|
||||||
|
if (result && !client.Recv(result, size)) {
|
||||||
fun = "Recv (2) failed";
|
fun = "Recv (2) failed";
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
@@ -102,8 +105,12 @@ int main(int argc, char** argv)
|
|||||||
resp += strlen(resp) + 1;
|
resp += strlen(resp) + 1;
|
||||||
if (resp < result + size)
|
if (resp < result + size)
|
||||||
fprintf(stderr, "%s", resp);
|
fprintf(stderr, "%s", resp);
|
||||||
|
if(result)
|
||||||
|
free(result);
|
||||||
exit(res);
|
exit(res);
|
||||||
fail:
|
fail:
|
||||||
|
if(result)
|
||||||
|
free(result);
|
||||||
if (fun)
|
if (fun)
|
||||||
fprintf(stderr, "luaclient: %s.\n", fun);
|
fprintf(stderr, "luaclient: %s.\n", fun);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
|
Reference in New Issue
Block a user