Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bugs of the openssl-related on the abyss server in the advanced edition #1

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions advanced/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ shell_config: $(BLDDIR)/config.mk
@echo 'FEATURE_LIST="$(FEATURE_LIST)"' >>$@
@echo 'PREFIX="$(PREFIX)"' >>$@
@echo 'HEADERINST_DIR="$(HEADERINST_DIR)"' >>$@
@echo 'PROGRAMINST_DIR="$(PROGRAMINST_DIR)"' >>$@
@echo 'LIBINST_DIR="$(LIBINST_DIR)"' >>$@
@echo 'BLDDIR="$(BLDDIR)"' >>$@
@echo 'ABS_SRCDIR="$(ABS_SRCDIR)"' >>$@
Expand Down Expand Up @@ -162,6 +163,7 @@ distdir: distdir-common
install: $(DEFAULT_SUBDIRS:%=%/install) install-common

HEADERDESTDIR = $(DESTDIR)$(HEADERINST_DIR)
PGROGRAMDESTDIR = $(DESTDIR)$(PROGRAMINST_DIR)

.PHONY: uninstall
uninstall: $(DEFAULT_SUBDIRS:%=%/uninstall) uninstall-common
Expand Down
7 changes: 5 additions & 2 deletions advanced/include/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,11 @@ ifeq ($(ENABLE_CGI_SERVER),yes)
COMPAT_LINK_CMDS += $(LN_S) xmlrpc-c/server_cgi.h xmlrpc_cgi.h;
endif

ifeq ($(HAVE_OPENSSL),Y)
HEADERS_TO_INSTALL += xmlrpc-c/openssl_thread.h
ifeq ($(HAVE_OPENSSL),yes)
HEADERS_TO_INSTALL += \
xmlrpc-c/openssl_thread.h \
xmlrpc-c/abyss_openssl.h \

endif

default: all
Expand Down
52 changes: 22 additions & 30 deletions advanced/lib/abyss/src/socket_openssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,11 @@ channelDestroy(TChannel * const channelP) {

struct ChannelOpenSsl * const channelOpenSslP = channelP->implP;

if (!channelOpenSslP->userSuppliedSsl)
if (!channelOpenSslP->userSuppliedSsl){
SSL_shutdown(channelOpenSslP->sslP);
SSL_free(channelOpenSslP->sslP);
}
close(channelOpenSslP->fd);

free(channelOpenSslP);
}
Expand Down Expand Up @@ -481,6 +484,7 @@ makeChannelFromSsl(SSL * const sslP,

channelOpenSslP->sslP = sslP;
channelOpenSslP->userSuppliedSsl = userSuppliedSsl;
channelOpenSslP->fd = SSL_get_fd(sslP);

/* This should be ok as far as I can tell */
ChannelCreate(&channelVtbl, channelOpenSslP, &channelP);
Expand Down Expand Up @@ -636,44 +640,32 @@ createChannelFromAcceptedConn(int const acceptedFd,
void ** const channelInfoPP,
const char ** const errorP) {

struct ChannelOpenSsl * channelOpenSslP;

MALLOCVAR(channelOpenSslP);

if (!channelOpenSslP)
xmlrpc_asprintf(errorP, "Unable to allocate memory");
else {
SSL * sslP;
const char * error;
SSL * sslP;
const char * error;

createSslFromAcceptedConn(acceptedFd, sslCtxP, &sslP, &error);
createSslFromAcceptedConn(acceptedFd, sslCtxP, &sslP, &error);

if (error) {
xmlrpc_asprintf(errorP, "Failed to create an OpenSSL connection "
"from the accepted TCP connection. %s", error);
xmlrpc_strfree(error);
} else {
struct abyss_openSsl_chaninfo * channelInfoP;
if (error) {
xmlrpc_asprintf(errorP, "Failed to create an OpenSSL connection "
"from the accepted TCP connection. %s", error);
xmlrpc_strfree(error);
} else {
struct abyss_openSsl_chaninfo * channelInfoP;

makeChannelInfo(&channelInfoP, sslP, errorP);
if (!*errorP) {
bool const userSuppliedFalse = false;
makeChannelInfo(&channelInfoP, sslP, errorP);
if (!*errorP) {
bool const userSuppliedFalse = false;

makeChannelFromSsl(sslP, userSuppliedFalse,
channelPP, errorP);
makeChannelFromSsl(sslP, userSuppliedFalse,
channelPP, errorP);

if (*errorP)
free(channelInfoP);
else
*channelInfoPP = channelInfoP;
}
if (*errorP)
SSL_free(sslP);
free(channelInfoP);
else
channelOpenSslP->sslP = sslP;
*channelInfoPP = channelInfoP;
}
if (*errorP)
free(channelOpenSslP);
SSL_free(sslP);
}
}

Expand Down