Fix log file being truncated on Windows.
This commit is contained in:
parent
c7d9cf3a3c
commit
0ce167c472
@ -8,6 +8,7 @@ Broker:
|
||||
- Various fixes around inflight quota management. Closes #2306.
|
||||
- Fix problem parsing config files with Windows line endings. Closes #2297.
|
||||
- Don't send retained messages when a shared subscription is made.
|
||||
- Fix log being truncated in Windows.
|
||||
|
||||
Client library:
|
||||
- Initialise sockpairR/W to invalid in `mosquitto_reinitialise()` to avoid
|
||||
|
@ -32,6 +32,7 @@ Contributors:
|
||||
# include <aclapi.h>
|
||||
# include <io.h>
|
||||
# include <lmcons.h>
|
||||
# include <fcntl.h>
|
||||
#else
|
||||
# include <sys/stat.h>
|
||||
#endif
|
||||
@ -45,6 +46,8 @@ FILE *mosquitto__fopen(const char *path, const char *mode, bool restrict_read)
|
||||
#ifdef WIN32
|
||||
char buf[4096];
|
||||
int rc;
|
||||
int flags = 0;
|
||||
|
||||
rc = ExpandEnvironmentStringsA(path, buf, 4096);
|
||||
if(rc == 0 || rc > 4096){
|
||||
return NULL;
|
||||
@ -64,9 +67,11 @@ FILE *mosquitto__fopen(const char *path, const char *mode, bool restrict_read)
|
||||
switch(mode[0]){
|
||||
case 'a':
|
||||
dwCreationDisposition = OPEN_ALWAYS;
|
||||
flags = _O_APPEND;
|
||||
break;
|
||||
case 'r':
|
||||
dwCreationDisposition = OPEN_EXISTING;
|
||||
flags = _O_RDONLY;
|
||||
break;
|
||||
case 'w':
|
||||
dwCreationDisposition = CREATE_ALWAYS;
|
||||
@ -88,6 +93,7 @@ FILE *mosquitto__fopen(const char *path, const char *mode, bool restrict_read)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(&sec, 0, sizeof(sec));
|
||||
sec.nLength = sizeof(SECURITY_ATTRIBUTES);
|
||||
sec.bInheritHandle = FALSE;
|
||||
sec.lpSecurityDescriptor = &sd;
|
||||
@ -100,7 +106,7 @@ FILE *mosquitto__fopen(const char *path, const char *mode, bool restrict_read)
|
||||
|
||||
LocalFree(pacl);
|
||||
|
||||
fd = _open_osfhandle((intptr_t)hfile, 0);
|
||||
fd = _open_osfhandle((intptr_t)hfile, flags);
|
||||
if (fd < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user