Uses stack-allocated array.

MD-20923
This commit is contained in:
Carles Pina 2014-11-20 12:45:04 +00:00
parent 3904349a06
commit 55f8918641

View file

@ -11,6 +11,7 @@
#include <string.h> #include <string.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include <vector>
class UpdateDialogGtk; class UpdateDialogGtk;
@ -31,6 +32,8 @@ UpdateDialogGtk* (*update_dialog_gtk_new)() = 0;
#define BIND_FUNCTION(library,function) \ #define BIND_FUNCTION(library,function) \
function = reinterpret_cast<TYPEOF(function)>(dlsym(library,#function)); function = reinterpret_cast<TYPEOF(function)>(dlsym(library,#function));
#define MAX_FILE_PATH 4096
bool extractFileFromBinary(int fd, const void* buffer, size_t length) bool extractFileFromBinary(int fd, const void* buffer, size_t length)
{ {
size_t count = write(fd,buffer,length); size_t count = write(fd,buffer,length);
@ -40,7 +43,8 @@ bool extractFileFromBinary(int fd, const void* buffer, size_t length)
UpdateDialog* UpdateDialogGtkFactory::createDialog() UpdateDialog* UpdateDialogGtkFactory::createDialog()
{ {
char* libPath = strdup("/tmp/mendeley-libUpdaterGtk.so.XXXXXX"); char libPath[MAX_FILE_PATH];
strncpy(libPath, "/tmp/mendeley-libUpdaterGtk.so.XXXXXX", MAX_FILE_PATH);
int libFd = mkostemp(libPath, O_CREAT | O_WRONLY | O_TRUNC); int libFd = mkostemp(libPath, O_CREAT | O_WRONLY | O_TRUNC);
if (libFd == -1) if (libFd == -1)