Date: Thu, 3 Aug 2006 04:30:41 GMT From: Elisey Savateev <b3k@mail.ru> To: freebsd-gnats-submit@FreeBSD.org Subject: ports/101296: [PATCH] www/c-icap: fixed serious bug in utf8 web pages recognition Message-ID: <200608030430.k734UfPj014308@www.freebsd.org> Resent-Message-ID: <200608030440.k734eFfL038603@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 101296 >Category: ports >Synopsis: [PATCH] www/c-icap: fixed serious bug in utf8 web pages recognition >Confidential: no >Severity: serious >Priority: high >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: maintainer-update >Submitter-Id: current-users >Arrival-Date: Thu Aug 03 04:40:15 GMT 2006 >Closed-Date: >Last-Modified: >Originator: Elisey Savateev >Release: FreeBSD 6.1-STABLE i386 >Organization: >Environment: FreeBSD beastie 6.1-STABLE FreeBSD 6.1-STABLE #1: Sat Jul 29 15:11:55 YEKST 2006 >Description: - Fixed serious bug in utf8 web pages recognition causing c-icap to enters an endless loop - Fixed typo in pkg-install - Added to Makefile LOG_DIR, RUN_DIR and TMP_DIR variables Added file(s): - files/c_icap.in - files/patch-filetype.c Removed file(s): - files/c_icap.sh.in >How-To-Repeat: >Fix: --- c-icap-030606_2,1.patch begins here --- diff -ruN --exclude=CVS /usr/ports/www/c-icap/Makefile /usr/home/bio3k/my_proj/ports/c-icap/c-icap/Makefile --- /usr/ports/www/c-icap/Makefile Fri Jun 16 00:24:04 2006 +++ /usr/home/bio3k/my_proj/ports/c-icap/c-icap/Makefile Thu Aug 3 10:18:58 2006 @@ -7,7 +7,7 @@ PORTNAME= c-icap PORTVERSION= 030606 -PORTREVISION= 1 +PORTREVISION= 2 PORTEPOCH= 1 CATEGORIES= www MASTER_SITES= ${MASTER_SITE_SOURCEFORGE} \ @@ -20,7 +20,7 @@ GNU_CONFIGURE= yes INSTALLS_SHLIB= yes -USE_RC_SUBR= c_icap.sh +USE_RC_SUBR= c_icap USE_AUTOTOOLS= libtool:15 CONFIGURE_TARGET= --build=${MACHINE_ARCH}-portbld-freebsd${OSREL} LDCONFIG_DIRS= %%PREFIX%%/lib %%PREFIX%%/lib/c_icap @@ -37,6 +37,14 @@ # Perl support not ready yet. Try to contact author or hack it by yourself. WITHOUT_PERL= yes +LOG_DIR= /var/log/c_icap +TMP_DIR= /var/tmp +RUN_DIR= /var/run +PLIST_SUB+= LOG_DIR=${LOG_DIR} RUN_DIR=${RUN_DIR} + +SUB_FILES= pkg-install pkg-deinstall +SUB_LIST= LOG_DIR=${LOG_DIR} TMP_DIR=${TMP_DIR} RUN_DIR=${RUN_DIR} + .if defined(WITH_PERL) USE_PERL5= yes PLIST_SUB+= PERL="" @@ -77,6 +85,9 @@ post-patch: @${REINPLACE_CMD} -e 's|User wwwrun|User cicap|g' \ -e 's|Group nobody|Group cicap|g' \ + -e 's|/var/run|${RUN_DIR}|g' \ + -e 's|/var/tmp|${TMP_DIR}|g' \ + -e 's|/var/log/c_icap|${LOG_DIR}|g' \ ${WRKSRC}/c-icap.conf.default ${WRKSRC}/c-icap.conf.default.in @${REINPLACE_CMD} -e 's|-lpthread|${PTHREAD_LIBS}|g' \ -e 's|icap_stretch_CFLAGS = -Iinclude/|icap_stretch_CFLAGS = -Iinclude/ ${PTHREAD_CFLAGS}|g' \ diff -ruN --exclude=CVS /usr/ports/www/c-icap/files/c_icap.in /usr/home/bio3k/my_proj/ports/c-icap/c-icap/files/c_icap.in --- /usr/ports/www/c-icap/files/c_icap.in Thu Jan 1 05:00:00 1970 +++ /usr/home/bio3k/my_proj/ports/c-icap/c-icap/files/c_icap.in Thu Aug 3 09:53:44 2006 @@ -0,0 +1,35 @@ +#!/bin/sh +# +# $FreeBSD: ports/www/c-icap/files/c_icap.sh.in,v 1.2 2006/06/11 08:33:03 pav Exp $ +# + +# PROVIDE: c-icap +# REQUIRE: DAEMON cleanvar +# BEFORE: LOGIN + +# +# Add the following lines to /etc/rc.conf to enable c-icap: +# +# c_icap_enable="YES" +# +# See '%%PREFIX%%/bin/c-icap --help' for flags +# + +. %%RC_SUBR%% + +name="c_icap" +rcvar=`set_rcvar` + +command="%%PREFIX%%/bin/c-icap" +pidfile="%%RUN_DIR%%/c-icap.pid" +required_dirs="%%TMP_DIR%%" +required_files="%%PREFIX%%/etc/c-icap.conf" + +stop_postcmd="rm -f $pidfile" + +# read settings, set default values +load_rc_config "$name" +: ${c_icap_enable="NO"} +: ${c_icap_flags=""} + +run_rc_command "$1" diff -ruN --exclude=CVS /usr/ports/www/c-icap/files/c_icap.sh.in /usr/home/bio3k/my_proj/ports/c-icap/c-icap/files/c_icap.sh.in --- /usr/ports/www/c-icap/files/c_icap.sh.in Tue Jun 13 20:52:46 2006 +++ /usr/home/bio3k/my_proj/ports/c-icap/c-icap/files/c_icap.sh.in Thu Jan 1 05:00:00 1970 @@ -1,35 +0,0 @@ -#!/bin/sh -# -# $FreeBSD: ports/www/c-icap/files/c_icap.sh.in,v 1.2 2006/06/11 08:33:03 pav Exp $ -# - -# PROVIDE: c-icap -# REQUIRE: DAEMON cleanvar -# BEFORE: LOGIN - -# -# Add the following lines to /etc/rc.conf to enable c-icap: -# -# c_icap_enable="YES" -# -# See '%%PREFIX%%/bin/c-icap --help' for flags -# - -. %%RC_SUBR%% - -name="c_icap" -rcvar=`set_rcvar` - -command="%%PREFIX%%/bin/c-icap" -pidfile="/var/run/c-icap.pid" -required_dirs="/var/tmp" -required_files="%%PREFIX%%/etc/c-icap.conf" - -stop_postcmd="rm -f $pidfile" - -# read settings, set default values -load_rc_config "$name" -: ${c_icap_enable="NO"} -: ${c_icap_flags=""} - -run_rc_command "$1" diff -ruN --exclude=CVS /usr/ports/www/c-icap/files/patch-filetype.c /usr/home/bio3k/my_proj/ports/c-icap/c-icap/files/patch-filetype.c --- /usr/ports/www/c-icap/files/patch-filetype.c Thu Jan 1 05:00:00 1970 +++ /usr/home/bio3k/my_proj/ports/c-icap/c-icap/files/patch-filetype.c Thu Aug 3 09:29:31 2006 @@ -0,0 +1,75 @@ +--- filetype.bak.c Sat May 13 22:51:32 2006 ++++ filetype.c Thu Aug 3 09:23:35 2006 +@@ -66,8 +66,9 @@ + } + + #define CHECK_SIZE(db,array,type,size) if(db->array##_num >= db->array##_size){\ +- if((newdata=realloc(db->array,db->array##_size+size*sizeof(type)))==NULL)\ ++ if((newdata=realloc(db->array,(db->array##_size+size)*sizeof(type)))==NULL)\ + return -1;\ ++ db->array##_size +=size; \ + db->array =newdata;\ + } + +@@ -80,7 +81,7 @@ + struct ci_data_type *newdata; + int indx,i; + +- CHECK_SIZE(db,types,struct ci_data_type,50); ++ CHECK_SIZE(db,types,struct ci_data_type,50) + + indx=db->types_num; + db->types_num++; +@@ -113,7 +114,7 @@ + int indx; + + CHECK_SIZE(db,magics,struct ci_magic,50) +- ++ + indx=db->magics_num; + db->magics_num++; + +@@ -308,6 +309,10 @@ + } + groups[i]=-1; + type=types_add(db,record.type,record.descr,groups); ++ if(type<0){ ++ ret=-2; ++ break; ++ } + } + + magics_add(db,record.offset,record.magic,record.len,type); +@@ -459,10 +464,13 @@ + int endian=0; + /*check for utf8 ........*/ + for(i=0;i<buflen;i+=ret){ +- if(!(ret=isUTF8(buf+i,buflen-i))) ++ if((ret=isUTF8(buf+i,buflen-i)) <= 0) + break; + } + ++ if(ret < 0 && i == 0) ++ ret=0;/*Not enough data to check*/ ++ + if(ret) /*Even if the last char is unknown ret!=0 mean is utf*/ + return CI_UTF_DATA; /*... but what about if buflen is about 2 or 3 bytes long ?*/ + +@@ -500,7 +508,7 @@ + + if((ret=check_magics(db,buf,buflen))>=0) + return ret; +- ++ + /*At the feature the check_ascii and check_unicode must be merged ....*/ + if((ret=check_ascii((unsigned char *)buf,buflen))>0) + return ret; +@@ -508,7 +516,7 @@ + if((ret=check_unicode((unsigned char *)buf,buflen))>0){ + return CI_UTF_DATA; + } +- ++ + return CI_BIN_DATA; /*binary data*/ + } + diff -ruN --exclude=CVS /usr/ports/www/c-icap/files/pkg-install.in /usr/home/bio3k/my_proj/ports/c-icap/c-icap/files/pkg-install.in --- /usr/ports/www/c-icap/files/pkg-install.in Tue Jun 13 20:52:46 2006 +++ /usr/home/bio3k/my_proj/ports/c-icap/c-icap/files/pkg-install.in Thu Aug 3 10:05:04 2006 @@ -1,13 +1,17 @@ #!/bin/sh # $FreeBSD: ports/www/c-icap/files/pkg-install.in,v 1.3 2006/06/11 08:33:03 pav Exp $ +DEST_DIR=${PKG_DESTDIR:-} + CICAP_USER=cicap CICAP_GROUP=cicap -LOG_PATH=/var/log/c_icap +LOG_DIR=$DEST_DIR%%LOG_DIR%% +TMP_DIR=$DEST_DIR%%TMP_DIR%% +RUN_DIR=$DEST_DIR%%RUN_DIR%% if [ "$2" = "PRE-INSTALL" ]; then - if ! pw groupshow "$CICAP_USER" 2>/dev/null 1>&2; then + if ! pw groupshow "$CICAP_GROUP" 2>/dev/null 1>&2; then if pw groupadd $CICAP_GROUP; then echo "=> Added group \"$CICAP_GROUP\"." else @@ -28,9 +32,21 @@ fi fi elif [ "$2" = "POST-INSTALL" ]; then - [ -d "$LOG_PATH" ] || mkdir -p "$LOG_PATH" || exit 1 - touch "$LOG_PATH/access.log" "$LOG_PATH/server.log" || exit 1 - chown -R "$CICAP_USER:$CICAP_GROUP" "$LOG_PATH" || exit 1 + if [ ! -d "$LOG_DIR" ]; then + mkdir -p "$LOG_DIR" || exit 1 + touch "$LOG_DIR/access.log" "$LOG_DIR/server.log" || exit 1 + chown -R "$CICAP_USER:$CICAP_GROUP" "$LOG_DIR" || exit 1 + fi + + if [ ! -d "$TMP_DIR" ]; then + mkdir -p "$TMP_DIR" || exit 1 + chown "$CICAP_USER:$CICAP_GROUP" "$TMP_DIR" || exit 1 + fi + + if [ ! -d "$RUN_DIR" ]; then + mkdir -p "$RUN_DIR" || exit 1 + chown "$CICAP_USER:$CICAP_GROUP" "$RUN_DIR" || exit 1 + fi fi exit 0 diff -ruN --exclude=CVS /usr/ports/www/c-icap/pkg-descr /usr/home/bio3k/my_proj/ports/c-icap/c-icap/pkg-descr --- /usr/ports/www/c-icap/pkg-descr Mon Mar 27 12:40:18 2006 +++ /usr/home/bio3k/my_proj/ports/c-icap/c-icap/pkg-descr Thu Aug 3 09:33:34 2006 @@ -5,6 +5,3 @@ authentication methods or access controlers. WWW: http://www.chtsanti.net/c-icap - -- Elisey Savateev -b3k@mail.ru diff -ruN --exclude=CVS /usr/ports/www/c-icap/pkg-plist /usr/home/bio3k/my_proj/ports/c-icap/c-icap/pkg-plist --- /usr/ports/www/c-icap/pkg-plist Tue Jun 13 20:52:46 2006 +++ /usr/home/bio3k/my_proj/ports/c-icap/c-icap/pkg-plist Thu Aug 3 09:47:24 2006 @@ -8,7 +8,7 @@ @unexec if cmp -s %D/etc/c-icap.magic %D/etc/c-icap.magic.default; then rm -f %D/etc/c-icap.magic; fi etc/c-icap.magic.default @exec [ -f %B/c-icap.magic ] || cp -p %%PREFIX%%/%F %B/c-icap.magic -@unexec [ ! -f /var/run/c-icap.pid ] || %D/etc/rc.d/c_icap stop +@unexec [ ! -f %%RUN_DIR%%/c-icap.pid ] || %D/etc/rc.d/c_icap stop include/c_icap/access.h include/c_icap/body.h include/c_icap/c-icap.h @@ -48,5 +48,4 @@ lib/libicapapi.la lib/libicapapi.so.0 lib/libicapapi.so -@cwd / -@dirrmtry var/log/c_icap +@unexec rmdir %%LOG_DIR%% 2>/dev/null || true --- c-icap-030606_2,1.patch ends here --- >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200608030430.k734UfPj014308>