mirror of
https://github.com/clearml/dropbear
synced 2025-03-10 05:50:15 +00:00
workaround memory sanitizer FD_ZERO false positives
This commit is contained in:
parent
5d065258da
commit
a60725740b
@ -152,8 +152,9 @@ void session_loop(void(*loophandler)(void)) {
|
|||||||
|
|
||||||
timeout.tv_sec = select_timeout();
|
timeout.tv_sec = select_timeout();
|
||||||
timeout.tv_usec = 0;
|
timeout.tv_usec = 0;
|
||||||
FD_ZERO(&writefd);
|
DROPBEAR_FD_ZERO(&writefd);
|
||||||
FD_ZERO(&readfd);
|
DROPBEAR_FD_ZERO(&readfd);
|
||||||
|
|
||||||
dropbear_assert(ses.payload == NULL);
|
dropbear_assert(ses.payload == NULL);
|
||||||
|
|
||||||
/* We get woken up when signal handlers write to this pipe.
|
/* We get woken up when signal handlers write to this pipe.
|
||||||
@ -204,8 +205,8 @@ void session_loop(void(*loophandler)(void)) {
|
|||||||
* want to iterate over channels etc for reading, to handle
|
* want to iterate over channels etc for reading, to handle
|
||||||
* server processes exiting etc.
|
* server processes exiting etc.
|
||||||
* We don't want to read/write FDs. */
|
* We don't want to read/write FDs. */
|
||||||
FD_ZERO(&writefd);
|
DROPBEAR_FD_ZERO(&writefd);
|
||||||
FD_ZERO(&readfd);
|
DROPBEAR_FD_ZERO(&readfd);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We'll just empty out the pipe if required. We don't do
|
/* We'll just empty out the pipe if required. We don't do
|
||||||
@ -406,7 +407,7 @@ static int ident_readln(int fd, char* buf, int count) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
FD_ZERO(&fds);
|
DROPBEAR_FD_ZERO(&fds);
|
||||||
|
|
||||||
/* select since it's a non-blocking fd */
|
/* select since it's a non-blocking fd */
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ process_file(hash_state *hs, const char *filename,
|
|||||||
timeout.tv_sec = 2;
|
timeout.tv_sec = 2;
|
||||||
timeout.tv_usec = 0;
|
timeout.tv_usec = 0;
|
||||||
|
|
||||||
FD_ZERO(&read_fds);
|
DROPBEAR_FD_ZERO(&read_fds);
|
||||||
FD_SET(readfd, &read_fds);
|
FD_SET(readfd, &read_fds);
|
||||||
res = select(readfd + 1, &read_fds, NULL, NULL, &timeout);
|
res = select(readfd + 1, &read_fds, NULL, NULL, &timeout);
|
||||||
if (res == 0)
|
if (res == 0)
|
||||||
|
7
dbutil.h
7
dbutil.h
@ -88,4 +88,11 @@ char * expand_homedir_path(const char *inpath);
|
|||||||
|
|
||||||
void fsync_parent_dir(const char* fn);
|
void fsync_parent_dir(const char* fn);
|
||||||
|
|
||||||
|
#if DROPBEAR_MSAN
|
||||||
|
/* FD_ZERO seems to leave some memory uninitialized. clear it to avoid false positives */
|
||||||
|
#define DROPBEAR_FD_ZERO(fds) do { memset((fds), 0x0, sizeof(fd_set)); FD_ZERO(fds); } while(0)
|
||||||
|
#else
|
||||||
|
#define DROPBEAR_FD_ZERO(fds) FD_ZERO(fds)
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* DROPBEAR_DBUTIL_H_ */
|
#endif /* DROPBEAR_DBUTIL_H_ */
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
#include "fuzz-wrapfd.h"
|
#include "fuzz-wrapfd.h"
|
||||||
|
|
||||||
|
#include "dbutil.h"
|
||||||
|
|
||||||
#include "fuzz.h"
|
#include "fuzz.h"
|
||||||
|
|
||||||
#define IOWRAP_MAXFD (FD_SETSIZE-1)
|
#define IOWRAP_MAXFD (FD_SETSIZE-1)
|
||||||
@ -195,7 +197,7 @@ int wrapfd_select(int nfds, fd_set *readfds, fd_set *writefds,
|
|||||||
nset++;
|
nset++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FD_ZERO(readfds);
|
DROPBEAR_FD_ZERO(readfds);
|
||||||
|
|
||||||
if (nset > 0) {
|
if (nset > 0) {
|
||||||
/* set one */
|
/* set one */
|
||||||
@ -222,7 +224,7 @@ int wrapfd_select(int nfds, fd_set *readfds, fd_set *writefds,
|
|||||||
nset++;
|
nset++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FD_ZERO(writefds);
|
DROPBEAR_FD_ZERO(writefds);
|
||||||
|
|
||||||
/* set one */
|
/* set one */
|
||||||
if (nset > 0) {
|
if (nset > 0) {
|
||||||
|
@ -178,7 +178,7 @@ static void main_noinetd() {
|
|||||||
/* incoming connection select loop */
|
/* incoming connection select loop */
|
||||||
for(;;) {
|
for(;;) {
|
||||||
|
|
||||||
FD_ZERO(&fds);
|
DROPBEAR_FD_ZERO(&fds);
|
||||||
|
|
||||||
/* listening sockets */
|
/* listening sockets */
|
||||||
for (i = 0; i < listensockcount; i++) {
|
for (i = 0; i < listensockcount; i++) {
|
||||||
|
11
sysoptions.h
11
sysoptions.h
@ -318,4 +318,15 @@ If you test it please contact the Dropbear author */
|
|||||||
|
|
||||||
#define DROPBEAR_TRACKING_MALLOC (DROPBEAR_FUZZ)
|
#define DROPBEAR_TRACKING_MALLOC (DROPBEAR_FUZZ)
|
||||||
|
|
||||||
|
/* Used to work around Memory Sanitizer false positives */
|
||||||
|
#if defined(__has_feature)
|
||||||
|
# if __has_feature(memory_sanitizer)
|
||||||
|
# define DROPBEAR_MSAN 1
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#ifndef DROPBEAR_MSAN
|
||||||
|
#define DROPBEAR_MSAN 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* no include guard for this file */
|
/* no include guard for this file */
|
||||||
|
Loading…
Reference in New Issue
Block a user