fixed stdout_read buffer overflow by removing it
This commit is contained in:
parent
699d25cdfe
commit
b43cc55aed
2 changed files with 4 additions and 14 deletions
|
@ -12,11 +12,8 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define BUFFER_SIZE 1024
|
|
||||||
|
|
||||||
#include "stockfish.h"
|
|
||||||
|
|
||||||
#include "fixes.h"
|
#include "fixes.h"
|
||||||
|
#include "stockfish.h"
|
||||||
|
|
||||||
const char *QUITOK = "quitok\n";
|
const char *QUITOK = "quitok\n";
|
||||||
|
|
||||||
|
@ -54,17 +51,10 @@ ssize_t stockfish_stdin_write(char *data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string data;
|
std::string data;
|
||||||
char buffer[BUFFER_SIZE + 1];
|
|
||||||
|
|
||||||
char* stockfish_stdout_read() {
|
const char *stockfish_stdout_read() {
|
||||||
if (getline(fakeout, data)) {
|
if (getline(fakeout, data)) {
|
||||||
size_t len = data.length();
|
return data.c_str();
|
||||||
size_t i;
|
|
||||||
for (i = 0; i < len && i < BUFFER_SIZE; i++) {
|
|
||||||
buffer[i] = data[i];
|
|
||||||
}
|
|
||||||
buffer[i] = 0;
|
|
||||||
return buffer;
|
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
|
@ -45,4 +45,4 @@ FFI_PLUGIN_EXPORT ssize_t stockfish_stdin_write(char *data);
|
||||||
#ifndef _ffigen
|
#ifndef _ffigen
|
||||||
extern "C"
|
extern "C"
|
||||||
#endif
|
#endif
|
||||||
FFI_PLUGIN_EXPORT char * stockfish_stdout_read();
|
FFI_PLUGIN_EXPORT const char * stockfish_stdout_read();
|
Loading…
Reference in a new issue