diff options
author | lurchi <lurchi@strangeplace.net> | 2018-01-07 16:18:32 +0100 |
---|---|---|
committer | lurchi <lurchi@strangeplace.net> | 2018-01-07 16:18:32 +0100 |
commit | dca5b11d13330d8e5252086f470ce0a895c00de1 (patch) | |
tree | 875be7ede98d562709f20a074822cf65c84c1259 /src/util/scheduler.c | |
parent | dbebf1ac6181b8ef4a89d01976f063a6ecf69fae (diff) | |
download | gnunet-dca5b11d13330d8e5252086f470ce0a895c00de1.tar.gz gnunet-dca5b11d13330d8e5252086f470ce0a895c00de1.zip |
fix dereferencing uninitialized rs/ws; assert non-NULL before dereferencing network/file handles
Diffstat (limited to 'src/util/scheduler.c')
-rw-r--r-- | src/util/scheduler.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/util/scheduler.c b/src/util/scheduler.c index fecbc0de5..9d37231e7 100644 --- a/src/util/scheduler.c +++ b/src/util/scheduler.c | |||
@@ -756,8 +756,9 @@ init_fd_info (struct GNUNET_SCHEDULER_Task *t, | |||
756 | t->fds = fdi; | 756 | t->fds = fdi; |
757 | if (1 == read_nh_len) | 757 | if (1 == read_nh_len) |
758 | { | 758 | { |
759 | GNUNET_assert (NULL != read_nh); | ||
760 | GNUNET_assert (NULL != *read_nh); | ||
759 | fdi->fd = *read_nh; | 761 | fdi->fd = *read_nh; |
760 | GNUNET_assert (NULL != fdi->fd); | ||
761 | fdi->et = GNUNET_SCHEDULER_ET_IN; | 762 | fdi->et = GNUNET_SCHEDULER_ET_IN; |
762 | fdi->sock = GNUNET_NETWORK_get_fd (*read_nh); | 763 | fdi->sock = GNUNET_NETWORK_get_fd (*read_nh); |
763 | t->read_fd = fdi->sock; | 764 | t->read_fd = fdi->sock; |
@@ -765,8 +766,9 @@ init_fd_info (struct GNUNET_SCHEDULER_Task *t, | |||
765 | } | 766 | } |
766 | else if (1 == write_nh_len) | 767 | else if (1 == write_nh_len) |
767 | { | 768 | { |
769 | GNUNET_assert (NULL != write_nh); | ||
770 | GNUNET_assert (NULL != *write_nh); | ||
768 | fdi->fd = *write_nh; | 771 | fdi->fd = *write_nh; |
769 | GNUNET_assert (NULL != fdi->fd); | ||
770 | fdi->et = GNUNET_SCHEDULER_ET_OUT; | 772 | fdi->et = GNUNET_SCHEDULER_ET_OUT; |
771 | fdi->sock = GNUNET_NETWORK_get_fd (*write_nh); | 773 | fdi->sock = GNUNET_NETWORK_get_fd (*write_nh); |
772 | t->read_fd = -1; | 774 | t->read_fd = -1; |
@@ -774,8 +776,9 @@ init_fd_info (struct GNUNET_SCHEDULER_Task *t, | |||
774 | } | 776 | } |
775 | else if (1 == read_fh_len) | 777 | else if (1 == read_fh_len) |
776 | { | 778 | { |
779 | GNUNET_assert (NULL != read_fh); | ||
780 | GNUNET_assert (NULL != *read_fh); | ||
777 | fdi->fh = *read_fh; | 781 | fdi->fh = *read_fh; |
778 | GNUNET_assert (NULL != fdi->fh); | ||
779 | fdi->et = GNUNET_SCHEDULER_ET_IN; | 782 | fdi->et = GNUNET_SCHEDULER_ET_IN; |
780 | fdi->sock = (*read_fh)->fd; // FIXME: does not work under WIN32 | 783 | fdi->sock = (*read_fh)->fd; // FIXME: does not work under WIN32 |
781 | t->read_fd = fdi->sock; | 784 | t->read_fd = fdi->sock; |
@@ -783,8 +786,9 @@ init_fd_info (struct GNUNET_SCHEDULER_Task *t, | |||
783 | } | 786 | } |
784 | else | 787 | else |
785 | { | 788 | { |
789 | GNUNET_assert (NULL != write_fh); | ||
790 | GNUNET_assert (NULL != *write_fh); | ||
786 | fdi->fh = *write_fh; | 791 | fdi->fh = *write_fh; |
787 | GNUNET_assert (NULL != fdi->fh); | ||
788 | fdi->et = GNUNET_SCHEDULER_ET_OUT; | 792 | fdi->et = GNUNET_SCHEDULER_ET_OUT; |
789 | fdi->sock = (*write_fh)->fd; // FIXME: does not work under WIN32 | 793 | fdi->sock = (*write_fh)->fd; // FIXME: does not work under WIN32 |
790 | t->read_fd = -1; | 794 | t->read_fd = -1; |
@@ -1750,8 +1754,11 @@ GNUNET_SCHEDULER_add_select (enum GNUNET_SCHEDULER_Priority prio, | |||
1750 | const struct GNUNET_DISK_FileHandle **write_fhandles; | 1754 | const struct GNUNET_DISK_FileHandle **write_fhandles; |
1751 | unsigned int read_nhandles_len, write_nhandles_len, | 1755 | unsigned int read_nhandles_len, write_nhandles_len, |
1752 | read_fhandles_len, write_fhandles_len; | 1756 | read_fhandles_len, write_fhandles_len; |
1757 | int no_fdsets = (NULL == rs) && (NULL == ws); | ||
1758 | int no_socket_descriptors = | ||
1759 | ((NULL != rs) && (0 == rs->nsds)) && ((NULL != ws) && (0 == ws->nsds)); | ||
1753 | 1760 | ||
1754 | if (((NULL == rs) && (NULL == ws)) || ((0 == rs->nsds) && (0 == ws->nsds))) | 1761 | if (no_fdsets || no_socket_descriptors) |
1755 | return GNUNET_SCHEDULER_add_delayed_with_priority (delay, | 1762 | return GNUNET_SCHEDULER_add_delayed_with_priority (delay, |
1756 | prio, | 1763 | prio, |
1757 | task, | 1764 | task, |