fixed stdout_read buffer overflow by removing it

This commit is contained in:
jusax23 2023-11-28 21:45:07 +01:00
parent 699d25cdfe
commit b43cc55aed
Signed by: jusax23
GPG key ID: 499E2AA870C1CD41
2 changed files with 4 additions and 14 deletions

View file

@ -12,11 +12,8 @@
#include <unistd.h>
#endif
#define BUFFER_SIZE 1024
#include "stockfish.h"
#include "fixes.h"
#include "stockfish.h"
const char *QUITOK = "quitok\n";
@ -54,17 +51,10 @@ ssize_t stockfish_stdin_write(char *data) {
}
std::string data;
char buffer[BUFFER_SIZE + 1];
char* stockfish_stdout_read() {
const char *stockfish_stdout_read() {
if (getline(fakeout, data)) {
size_t len = data.length();
size_t i;
for (i = 0; i < len && i < BUFFER_SIZE; i++) {
buffer[i] = data[i];
}
buffer[i] = 0;
return buffer;
return data.c_str();
}
return nullptr;
}

View file

@ -45,4 +45,4 @@ FFI_PLUGIN_EXPORT ssize_t stockfish_stdin_write(char *data);
#ifndef _ffigen
extern "C"
#endif
FFI_PLUGIN_EXPORT char * stockfish_stdout_read();
FFI_PLUGIN_EXPORT const char * stockfish_stdout_read();