From 6f68ea16e97a8245a8ca28272c2c7e0a9b447ae3 Mon Sep 17 00:00:00 2001 From: helge Date: Wed, 26 Mar 2008 18:50:50 +0000 Subject: [PATCH] fixed some potential crashers git-svn-id: http://svn.opengroupware.org/SOPE/trunk@1619 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- sope-appserver/mod_ngobjweb/ChangeLog | 7 +++++++ sope-appserver/mod_ngobjweb/GNUmakefile | 8 +++++--- .../mod_ngobjweb/NGBufferedDescriptor.c | 15 ++++++++------- sope-appserver/mod_ngobjweb/README | 9 +++++++++ sope-appserver/mod_ngobjweb/handler.c | 9 +++------ sope-appserver/mod_ngobjweb/ngobjweb_module.c | 2 +- 6 files changed, 33 insertions(+), 17 deletions(-) diff --git a/sope-appserver/mod_ngobjweb/ChangeLog b/sope-appserver/mod_ngobjweb/ChangeLog index acac6fb9..12ab20d6 100644 --- a/sope-appserver/mod_ngobjweb/ChangeLog +++ b/sope-appserver/mod_ngobjweb/ChangeLog @@ -1,3 +1,10 @@ +2008-03-26 Helge Hess + + * handler.c: fixed a double free() crasher, as reported by Stephane + + * NGBufferedDescriptor.c (NGBufferedDescriptor_read): fixed a + potential crasher, discovered by Stephane + 2007-07-19 Wolfgang Sourdeau * GNUmakefile: include APR CFLAGS and LDFLAGS in compilation (fixes OGo diff --git a/sope-appserver/mod_ngobjweb/GNUmakefile b/sope-appserver/mod_ngobjweb/GNUmakefile index 0d80445c..67e71c6d 100644 --- a/sope-appserver/mod_ngobjweb/GNUmakefile +++ b/sope-appserver/mod_ngobjweb/GNUmakefile @@ -50,7 +50,7 @@ ifneq ($(APXS),) ifneq ($(shared),no) APXS_CFLAGS = $(shell $(APXS) -q CFLAGS_SHLIB) $(shell $(APXS) -q CFLAGS) APXS_INCLUDE_DIRS = -I$(shell $(APXS) -q INCLUDEDIR) -APXS_LIBS = -l$(shell$ (APXS) -q LIBS_SHLIB) +APXS_LIBS = $(shell$ (APXS) -q LIBS_SHLIB) APXS_LDFLAGS = $(shell $(APXS) -q LDFLAGS_SHLIB) else ifneq ($(APXS),) @@ -70,7 +70,8 @@ endif ifneq ($(APR),) APR_INCLUDE_DIRS = -I$(shell $(APR) --includedir) APR_CFLAGS = $(shell $(APR) --cppflags) -APR_LDFLAGS = $(shell $(APR) --ldflags --libs) +APR_LDFLAGS = $(shell $(APR) --ldflags) +APR_LIBS = $(shell $(APR) --libs) endif GNUSTEP_INSTALLATION_DIR = $(GNUSTEP_SYSTEM_ROOT)/Library/WOAdaptors/Apache @@ -84,6 +85,7 @@ CFLAGS = -Wall -I. -fPIC \ $(APXS_INCLUDE_DIRS) $(APR_INCLUDE_DIRS) LDFLAGS = $(APXS_LDFLAGS) $(APR_LDFLAGS) -shared -fPIC +LDLIBS = $(APXS_LIBS) $(APR_LIBS) # adaptor @@ -116,4 +118,4 @@ install-usr-libexec :: all $(INSTALL_PROGRAM) $(product) /usr/libexec/httpd/ $(product) : $(OFILES) - $(LD) $(LDFLAGS) -o $@ $(OFILES) $(EXTRA_LDFLAGS) + $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) -o $@ $(OFILES) $(LDLIBS) diff --git a/sope-appserver/mod_ngobjweb/NGBufferedDescriptor.c b/sope-appserver/mod_ngobjweb/NGBufferedDescriptor.c index 7c16dda4..f09b9097 100644 --- a/sope-appserver/mod_ngobjweb/NGBufferedDescriptor.c +++ b/sope-appserver/mod_ngobjweb/NGBufferedDescriptor.c @@ -112,15 +112,16 @@ int NGBufferedDescriptor_getWriteBufferSize(NGBufferedDescriptor *self) { } int NGBufferedDescriptor_read(NGBufferedDescriptor *self, - void *_buf, int _len) { - register int availBytes = numberOfAvailableReadBufferBytes(self); - + void *_buf, int _len) +{ + register int availBytes; + if (self == NULL) return 0; - if (self->readBufferSize == 0) { // no read buffering is done (buffersize==0) + if (self->readBufferSize == 0) // no read buffering is done (buffersize==0) return read(self->fd, _buf, _len); - } - + + availBytes = numberOfAvailableReadBufferBytes(self); if (availBytes >= _len) { // there are enough bytes in the buffer to fulfill the request if (_len == 1) { @@ -129,7 +130,7 @@ int NGBufferedDescriptor_read(NGBufferedDescriptor *self, } else { memcpy(_buf, self->readBufferPos, _len); - self->readBufferPos += _len; // update read position (consumed-size) + self->readBufferPos += _len; // update read position (consumed-size) } checkReadBufferFillState(self); // check whether all bytes where consumed return _len; diff --git a/sope-appserver/mod_ngobjweb/README b/sope-appserver/mod_ngobjweb/README index c84d3d30..6da129c7 100644 --- a/sope-appserver/mod_ngobjweb/README +++ b/sope-appserver/mod_ngobjweb/README @@ -47,6 +47,15 @@ Then run: Finally create a proper OGo.conf in /etc/apache/conf.d. + +Apache2 on MacOSX 10.5 +====================== + +So you need to add the APR include dir to the make call, eg: + + make apxs=/usr/sbin/apxs apr=/usr/bin/apr-1-config \ + EXTRA_LDFLAGS="-bundle -undefined error -dynamic" + Apache2 on SuSE 9.0 =================== diff --git a/sope-appserver/mod_ngobjweb/handler.c b/sope-appserver/mod_ngobjweb/handler.c index 418d6fe7..0bef55b0 100644 --- a/sope-appserver/mod_ngobjweb/handler.c +++ b/sope-appserver/mod_ngobjweb/handler.c @@ -717,15 +717,12 @@ int ngobjweb_handler(request_rec *r) { // read whole response if (!NGBufferedDescriptor_safeRead(toApp, buffer, contentLength)) { - if (toApp) NGBufferedDescriptor_free(toApp); + if (toApp != NULL) { NGBufferedDescriptor_free(toApp); toApp = NULL; } } // close connection to app - if (toApp) { - NGBufferedDescriptor_free(toApp); - toApp = NULL; - } - + if (toApp != NULL) { NGBufferedDescriptor_free(toApp); toApp = NULL; } + ap_log_error(__FILE__, __LINE__, APLOG_INFO, 0, r->server, "send response (size=%i)", contentLength); diff --git a/sope-appserver/mod_ngobjweb/ngobjweb_module.c b/sope-appserver/mod_ngobjweb/ngobjweb_module.c index 96b62b69..847bead1 100644 --- a/sope-appserver/mod_ngobjweb/ngobjweb_module.c +++ b/sope-appserver/mod_ngobjweb/ngobjweb_module.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2005 SKYRIX Software AG + Copyright (C) 2000-2008 SKYRIX Software AG This file is part of SOPE. -- 2.39.5