Re: unrtf segmentation fault

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: unrtf segmentation fault

Stuart Henderson
On 2011/06/09 18:17, [hidden email] wrote:
> OS OpenBSD 4.9 upgraded from 4.8
>
> Command 'unrtf file.rtf' give me segmentation fault.
> File seem regular because it can be converted on linux.
>

OpenBSD's malloc picks up a lot of application bugs that wouldn't
be noticed on other OS without specialist debugging tools.

http://www.openbsd.org/papers/eurobsdcon2009/otto-malloc.pdf
http://www.undeadly.org/cgi?action=article&sid=20080708155228
http://en.wikipedia.org/wiki/Malloc#OpenBSD.27s_malloc

This does mean that you'll see more segfaults with buggy software,
but that means you get a better chance to debug them and get the
problem fixed, rather than have something silently proceed even
though there's a bug (only to have it intermittently fail in hard
to diagnose ways).

In general if you have segfaults you'll either need to provide
a backtrace, or provide a way to repeat it (this definitely
doesn't happen on every file with unrtf). But in this case
the version of unrtf in ports is ancient so there's no
point digging into it, I'll look at updating it, then if it
still fails with the new one you'll need to provide either
the file or a backtrace.

Please honour Reply-To: which is set to ports@.

Reply | Threaded
Open this post in threaded view
|

Re: unrtf segmentation fault

Stuart Henderson
On 2011-06-10, Stuart Henderson <[hidden email]> wrote:
> On 2011/06/09 18:17, [hidden email] wrote:
>> OS OpenBSD 4.9 upgraded from 4.8
>>
>> Command 'unrtf file.rtf' give me segmentation fault.
>> File seem regular because it can be converted on linux.
>
...
> In general if you have segfaults you'll either need to provide
> a backtrace, or provide a way to repeat it (this definitely
> doesn't happen on every file with unrtf). But in this case
> the version of unrtf in ports is ancient so there's no
> point digging into it, I'll look at updating it, then if it
> still fails with the new one you'll need to provide either
> the file or a backtrace.

here's a start of a diff to update it, but ugh...
it fails its own regression tests unless:

1. it's compiled with -O0
and
2. you disable malloc.conf options for picking up more bugs (FGJ etc).

Index: Makefile
===================================================================
RCS file: /cvs/ports/textproc/unrtf/Makefile,v
retrieving revision 1.10
diff -u -p -r1.10 Makefile
--- Makefile 14 Mar 2011 20:49:50 -0000 1.10
+++ Makefile 10 Jun 2011 11:05:46 -0000
@@ -1,33 +1,38 @@
-# $OpenBSD: Makefile,v 1.10 2011/03/14 20:49:50 jasper Exp $
+# $OpenBSD: Makefile.template,v 1.54 2008/01/13 16:43:57 espie Exp $
 
 COMMENT= RTF document converter
 
-VERSION= 0.19.3
-DISTNAME= unrtf-${VERSION}
-REVISION= 0
+DISTNAME= unrtf-0.21.2
 CATEGORIES= textproc
 
-HOMEPAGE= http://www.gnu.org/software/unrtf/unrtf.html
+HOMEPAGE=
+
+# GPLv3+
+PERMIT_PACKAGE_CDROM= Yes
+PERMIT_PACKAGE_FTP= Yes
+PERMIT_DISTFILES_CDROM= Yes
+PERMIT_DISTFILES_FTP= Yes
+
+WANTLIB += c
 
 MASTER_SITES= ${MASTER_SITE_GNU:=unrtf/}
 
-# GPL
-PERMIT_PACKAGE_CDROM=   Yes
-PERMIT_PACKAGE_FTP=     Yes
-PERMIT_DISTFILES_CDROM= Yes
-PERMIT_DISTFILES_FTP=   Yes
-WANTLIB= c
-
-MAKE_FLAGS= CFLAGS='${CFLAGS}' CC='${CC}'
-USE_GROFF = Yes
-
-do-install:
- ${INSTALL_PROGRAM} ${WRKSRC}/unrtf ${PREFIX}/bin
- ${INSTALL_DATA_DIR} ${PREFIX}/share/doc/unrtf
- ${INSTALL_DATA} ${WRKSRC}/doc/unrtf.html ${PREFIX}/share/doc/unrtf/unrtf.html
- ${INSTALL_MAN} ${WRKSRC}/unrtf.1 ${PREFIX}/man/man1
+MODULES= converters/libiconv
+REGRESS_DEPENDS=${FULLPKGPATH}
 
-REGRESS_TARGET= tests
-REGRESS_FLAGS= PATH=${WRKSRC}
+SEPARATE_BUILD= simple
+USE_GMAKE = Yes
+CONFIGURE_STYLE = autoconf
+AUTOCONF_VERSION= 2.63
+CONFIGURE_ARGS+= --libdir=${PREFIX}/share \
+ CPPFLAGS="-I${LOCALBASE}/include" \
+ LDFLAGS="${LDFLAGS}"
+
+LDFLAGS+= -L${LOCALBASE}/lib
+
+pre-configure:
+ cd ${WRKSRC}; \
+    perl -pi -e 's,/usr/local/lib/unrtf,${TRUEPREFIX}/share/unrtf,' \
+    doc/unrtf.1 src/my_iconv.h src/path.h src/main.h
 
 .include <bsd.port.mk>
Index: distinfo
===================================================================
RCS file: /cvs/ports/textproc/unrtf/distinfo,v
retrieving revision 1.4
diff -u -p -r1.4 distinfo
--- distinfo 5 Apr 2007 17:26:19 -0000 1.4
+++ distinfo 10 Jun 2011 11:05:46 -0000
@@ -1,5 +1,5 @@
-MD5 (unrtf-0.19.3.tar.gz) = 5+7cpVnv2Uuvb5VB11EKmw==
-RMD160 (unrtf-0.19.3.tar.gz) = EnOXEq7NO8vXMMtn5/x+37wyECQ=
-SHA1 (unrtf-0.19.3.tar.gz) = r2VLKnmk+gYI26RRofLQsVk5mKU=
-SHA256 (unrtf-0.19.3.tar.gz) = Wq7egLr3M6ed6xMhD/MywTjwrdlhGlHxLvdSKYg44k8=
-SIZE (unrtf-0.19.3.tar.gz) = 127770
+MD5 (unrtf-0.21.2.tar.gz) = 4LONh4bwBwTsR5p9JhgIuA==
+RMD160 (unrtf-0.21.2.tar.gz) = GA0WrEO6xe8opK+2WlZKNMuL750=
+SHA1 (unrtf-0.21.2.tar.gz) = IHYUqNzMEzSuEkoXNOq/OJNgKAI=
+SHA256 (unrtf-0.21.2.tar.gz) = rLGwk90sdIX8Q7EozK9mXWGI9Wh1LOyW1UtpM3TK3bA=
+SIZE (unrtf-0.21.2.tar.gz) = 617656
Index: patches/patch-Makefile
===================================================================
RCS file: patches/patch-Makefile
diff -N patches/patch-Makefile
--- patches/patch-Makefile 21 Aug 2002 15:43:37 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,21 +0,0 @@
-$OpenBSD: patch-Makefile,v 1.1.1.1 2002/08/21 15:43:37 espie Exp $
---- Makefile.orig Wed Oct  3 06:45:59 2001
-+++ Makefile Wed Aug 21 17:29:51 2002
-@@ -35,7 +35,7 @@ OBJS=convert.o word.o error.o main.o has
- TARGET=unrtf
-
- ${TARGET}: ${OBJS}
-- gcc ${OBJS} -o ${TARGET}
-+ $(CC) $(CFLAGS) ${OBJS} -o ${TARGET}
-
- clean:
- rm -f ${OBJS} ${TARGET} bcount bcount.o
-@@ -46,7 +46,7 @@ tidy:
-
- tests:
- ${TARGET} test/table.rtf > test/table.html
-- ${TARGET} test/slashnewline.rtf > test/slashnewline.html
-+ ${TARGET} test/slashnew.rtf > test/slashnew.html
- ${TARGET} test/fontface.rtf > test/fontface.html
- ${TARGET} test/fontsize.rtf > test/fontsize.html
-
Index: patches/patch-configure_ac
===================================================================
RCS file: patches/patch-configure_ac
diff -N patches/patch-configure_ac
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-configure_ac 10 Jun 2011 11:05:46 -0000
@@ -0,0 +1,11 @@
+$OpenBSD$
+--- configure.ac.orig Fri Jun 10 11:09:16 2011
++++ configure.ac Fri Jun 10 11:09:20 2011
+@@ -44,6 +44,7 @@ AC_CHECK_FUNCS([memset strchr strstr])
+ AC_CANONICAL_HOST
+ case $host in
+     *-*-cygwin*) AC_SUBST(LIBS, ["-liconv"]);;
++    *openbsd*) AC_SUBST(LIBS, ["-liconv"]);;
+     *aix*) AC_SUBST(LIBS, ["-liconv"]);;
+ esac
+
Index: patches/patch-convert_c
===================================================================
RCS file: patches/patch-convert_c
diff -N patches/patch-convert_c
--- patches/patch-convert_c 15 May 2005 18:09:41 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,84 +0,0 @@
-$OpenBSD: patch-convert_c,v 1.2 2005/05/15 18:09:41 db Exp $
---- convert.c.orig Thu Feb 19 00:35:03 2004
-+++ convert.c Thu May 12 13:03:29 2005
-@@ -341,7 +341,7 @@ process_font_table (Word *w)
- while(w2) {
- tmp = word_string (w2);
- if (tmp && tmp[0] != '\\')
-- strcat(name,tmp);
-+ strlcat(name,tmp,sizeof(name) - strlen(name) - 1);
-
- w2=w2->next;
- }
-@@ -676,7 +676,7 @@ cmd_cf (Word *w, int align, char has_par
- }
- else
- {
-- sprintf (str,"#%02x%02x%02x",
-+ snprintf (str, sizeof(str), "#%02x%02x%02x",
- color_table[num].r,
- color_table[num].g,
- color_table[num].b);
-@@ -703,7 +703,7 @@ cmd_cb (Word *w, int align, char has_par
- }
- else
- {
-- sprintf (str,"#%02x%02x%02x",
-+ snprintf (str, sizeof(str), "#%02x%02x%02x",
- color_table[num].r,
- color_table[num].g,
- color_table[num].b);
-@@ -728,7 +728,7 @@ cmd_fs (Word *w, int align, char has_par
- /* Note, fs20 means 10pt */
- points /= 2;
-
-- sprintf (str,"%d",points);
-+ snprintf (str, sizeof(str), "%d",points);
- attr_push(ATTR_FONTSIZE,str);
-
- return FALSE;
-@@ -862,7 +862,7 @@ cmd_highlight (Word *w, int align, char
- }
- else
- {
-- sprintf (str,"#%02x%02x%02x",
-+ snprintf (str, sizeof(str), "#%02x%02x%02x",
- color_table[num].r,
- color_table[num].g,
- color_table[num].b);
-@@ -1019,7 +1019,7 @@ static int
- cmd_expand (Word *w, int align, char has_param, short param) {
- char str[10];
- if (has_param) {
-- sprintf (str, "%d", param/4);
-+ snprintf (str, sizeof(str), "%d", param/4);
- if (!param)
- attr_pop(ATTR_EXPAND);
- else
-@@ -1043,7 +1043,7 @@ cmd_emboss (Word *w, int align, char has
- attr_pop(ATTR_EMBOSS);
- else
- {
-- sprintf (str, "%d", param);
-+ snprintf (str, sizeof(str), "%d", param);
- attr_push(ATTR_EMBOSS, str);
- }
- return FALSE;
-@@ -1064,7 +1064,7 @@ cmd_engrave (Word *w, int align, char ha
- attr_pop(ATTR_ENGRAVE);
- else
- {
-- sprintf (str, "%d", param);
-+ snprintf (str, sizeof(str), "%d", param);
- attr_push(ATTR_ENGRAVE, str);
- }
- return FALSE;
-@@ -2610,7 +2610,7 @@ word_print_core (Word *w)
- case PICT_DI: ext="dib"; break; /* Device independent bitmap=??? */
- case PICT_PM: ext="pmm"; break; /* OS/2 metafile=??? */
- }
-- sprintf (picture_path, "pict%03d.%s",
-+ snprintf (picture_path, sizeof(picture_path), "pict%03d.%s",
- picture_file_number++,ext);
- f=fopen(picture_path,"w");
- }
Index: patches/patch-defs_h
===================================================================
RCS file: patches/patch-defs_h
diff -N patches/patch-defs_h
--- patches/patch-defs_h 15 May 2005 18:09:41 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,12 +0,0 @@
-$OpenBSD: patch-defs_h,v 1.1 2005/05/15 18:09:41 db Exp $
---- defs.h.orig Thu May 12 13:07:16 2005
-+++ defs.h Thu May 12 13:07:26 2005
-@@ -37,7 +37,7 @@
-  *--------------------------------------------------------------------*/
-
-
--#define PROGRAM_VERSION "0.19.2"
-+#define PROGRAM_VERSION "0.19.3"
- #define PROGRAM_NAME "UnRTF"
- #define PROGRAM_WEBSITE "http://www.gnu.org/software/unrtf/unrtf.html"
-
Index: patches/patch-malloc_c
===================================================================
RCS file: patches/patch-malloc_c
diff -N patches/patch-malloc_c
--- patches/patch-malloc_c 15 May 2005 18:09:41 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,19 +0,0 @@
-$OpenBSD: patch-malloc_c,v 1.1 2005/05/15 18:09:41 db Exp $
---- malloc.c.orig Thu Feb 19 00:35:03 2004
-+++ malloc.c Thu May 12 12:51:46 2005
-@@ -39,14 +39,8 @@
-
- #include <stdio.h>
- #include <string.h>
--#if linux /* daved - 0.19.0 */
-+#if linux || defined(__OpenBSD__) /* daved - 0.19.0 */
- #include <stdlib.h>
--#endif
--
--#if AMIGA
--#include <stdlib.h>
--#else
--#include <malloc.h>
- #endif
-
- #include "error.h"
Index: patches/patch-output_c
===================================================================
RCS file: patches/patch-output_c
diff -N patches/patch-output_c
--- patches/patch-output_c 15 May 2005 18:09:41 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,21 +0,0 @@
-$OpenBSD: patch-output_c,v 1.1 2005/05/15 18:09:41 db Exp $
---- output.c.orig Thu May 12 13:04:27 2005
-+++ output.c Thu May 12 13:04:57 2005
-@@ -218,7 +218,7 @@ op_begin_std_fontsize (OutputPersonality
- if (!found_std_expr) {
- if (op->fontsize_begin) {
- char expr[16];
-- sprintf (expr, "%d", size);
-+ snprintf (expr, sizeof(expr), "%d", size);
- printf (op->fontsize_begin, expr);
- } else {
- /* If we cannot write out a change for the exact
-@@ -347,7 +347,7 @@ op_end_std_fontsize (OutputPersonality *
- if (!found_std_expr) {
- if (op->fontsize_end) {
- char expr[16];
-- sprintf (expr, "%d", size);
-+ snprintf (expr, sizeof(expr), "%d", size);
- printf (op->fontsize_end, expr);
- } else {
- /* If we cannot write out a change for the exact
Index: patches/patch-ps_c
===================================================================
RCS file: patches/patch-ps_c
diff -N patches/patch-ps_c
--- patches/patch-ps_c 15 May 2005 18:09:41 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,696 +0,0 @@
-$OpenBSD: patch-ps_c,v 1.2 2005/05/15 18:09:41 db Exp $
---- ps.c.orig Thu Feb 19 00:35:03 2004
-+++ ps.c Thu May 12 12:46:35 2005
-@@ -116,352 +116,350 @@ static char* cp850 [] = {
-
-
-
--#define PS_END "\
--%% --------- \n\n\
--  didShowPage not { \n\
--    showpage \n\
--  } if\n\n\
--%%%%EOF\n"
-+#define PS_END \
-+"%% --------- \n\n"\
-+"  didShowPage not { \n"\
-+"    showpage \n"\
-+"  } if\n\n"\
-+"%%%%EOF\n"
-
-
-
-
--#define PS_START "\
--%%%%!PS\n\
--%%--------------------------------------------------------------------------\n\
--%% GNU UnRTF, a command-line program to convert RTF documents to other formats.\n\
--%% Copyright (C) 2000,2001 Zachary Thayer Smith\n\
--%%\n\
--%% This program is free software; you can redistribute it and/or modify\n\
--%% it under the terms of the GNU General Public License as published by\n\
--%% the Free Software Foundation; either version 2 of the License, or\n\
--%% (at your option) any later version.\n\
--%%\n\
--%% This program is distributed in the hope that it will be useful,\n\
--%% but WITHOUT ANY WARRANTY; without even the implied warranty of\n\
--%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n\
--%% GNU General Public License for more details.\n\
--%%\n\
--%% You should have received a copy of the GNU General Public License\n\
--%% along with this program; if not, write to the Free Software\n\
--%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\n\
--%%\n\
--%% The author is reachable by electronic mail at [hidden email].\n\
--%%--------------------------------------------------------------------------\n\
--%%%%EndComments \n\
--%%\n\
--%%         --------- Note, this PS code is unfinished -------- \n\
--%%         --------- Note, this PS code is unfinished -------- \n\
--%%         --------- Note, this PS code is unfinished -------- \n\
--%%         --------- Note, this PS code is unfinished -------- \n\
--%%         --------- Note, this PS code is unfinished -------- \n\
--%%\n\
--%% ----------- Variables ------------\n\
--/fontFamily /Times def\n\
--/fontAscent 0 def %% ascent for current font\n\
--/fontDescent 0 def %% descent for current font\n\
--/lineAscent 0 def \n\
--/lineDescent 0 def \n\
--/pageWidthInches 8.5 def \n\
--/pageHeightInches 11 def \n\
--/leftMargin 20 def \n\
--/rightMargin 20 def \n\
--/topMargin 20 def \n\
--/bottomMargin 20 def \n\
--/DPI 72 def \n\
--/pageWidth pageWidthInches DPI mul def \n\
--/rightLimit pageWidth rightMargin sub def \n\
--/pageHeight pageHeightInches DPI mul def \n\
--/x 0 def \n\
--/y 0 def \n\
--/bold false def \n\
--/italic false def \n\
--/underline false def \n\
--/overline false def \n\
--/intercharSpace 0 def \n\
--/strike false def \n\
--/outline false def \n\
--/shadow false def \n\
--/fontSize 12 def \n\
--/didBR false def \n\
--/didParSkip false def \n\
--/didShowPage false def \n\
--%%------------------------------------------------------\n\
--%% Set up the ISO fonts \n\
--\n\
--%% Times \n\
--%% ----- \n\
--/Times-Roman findfont dup length dict begin { \n\
-- 1 index /FID ne { def } { pop pop } ifelse \n\
--} forall \n\
--/Encoding ISOLatin1Encoding def \n\
--currentdict end \n\
--/TRomanISO exch definefont pop \n\n\
--/Times-Bold findfont dup length dict begin { \n\
-- 1 index /FID ne { def } { pop pop } ifelse \n\
--} forall \n\
--/Encoding ISOLatin1Encoding def \n\
--currentdict end \n\
--/TBoldISO exch definefont pop \n\n\
--/Times-BoldItalic findfont dup length dict begin { \n\
-- 1 index /FID ne { def } { pop pop } ifelse \n\
--} forall \n\
--/Encoding ISOLatin1Encoding def \n\
--currentdict end \n\
--/TBoldItalicISO exch definefont pop \n\n\
--/Times-Italic findfont dup length dict begin { \n\
-- 1 index /FID ne { def } { pop pop } ifelse \n\
--} forall \n\
--/Encoding ISOLatin1Encoding def \n\
--currentdict end \n\
--/TItalicISO exch definefont pop \n\n\
--%% Courier \n\
--%% ----- \n\
--/Courier-Roman findfont dup length dict begin { \n\
-- 1 index /FID ne { def } { pop pop } ifelse \n\
--} forall \n\
--/Encoding ISOLatin1Encoding def \n\
--currentdict end \n\
--/CRomanISO exch definefont pop \n\n\
--/Courier-Bold findfont dup length dict begin { \n\
-- 1 index /FID ne { def } { pop pop } ifelse \n\
--} forall \n\
--/Encoding ISOLatin1Encoding def \n\
--currentdict end \n\
--/CBoldISO exch definefont pop \n\n\
--/Courier-BoldItalic findfont dup length dict begin { \n\
-- 1 index /FID ne { def } { pop pop } ifelse \n\
--} forall \n\
--/Encoding ISOLatin1Encoding def \n\
--currentdict end \n\
--/CBoldItalicISO exch definefont pop \n\n\
--/Courier-Italic findfont dup length dict begin { \n\
-- 1 index /FID ne { def } { pop pop } ifelse \n\
--} forall \n\
--/Encoding ISOLatin1Encoding def \n\
--currentdict end \n\
--/CItalicISO exch definefont pop \n\n\
--%% Symbol \n\
--%% ----- \n\
--/Symbol-Roman findfont dup length dict begin { \n\
-- 1 index /FID ne { def } { pop pop } ifelse \n\
--} forall \n\
--/Encoding ISOLatin1Encoding def \n\
--currentdict end \n\
--/SRomanISO exch definefont pop \n\n\
--/Symbol-Bold findfont dup length dict begin { \n\
-- 1 index /FID ne { def } { pop pop } ifelse \n\
--} forall \n\
--/Encoding ISOLatin1Encoding def \n\
--currentdict end \n\
--/SBoldISO exch definefont pop \n\n\
--/Symbol-BoldItalic findfont dup length dict begin { \n\
-- 1 index /FID ne { def } { pop pop } ifelse \n\
--} forall \n\
--/Encoding ISOLatin1Encoding def \n\
--currentdict end \n\
--/SBoldItalicISO exch definefont pop \n\n\
--/Symbol-Italic findfont dup length dict begin { \n\
-- 1 index /FID ne { def } { pop pop } ifelse \n\
--} forall \n\
--/Encoding ISOLatin1Encoding def \n\
--currentdict end \n\
--/SItalicISO exch definefont pop \n\n\
--%% Helvetica \n\
--%% --------- \n\
--/Helvetica-Roman findfont dup length dict begin { \n\
-- 1 index /FID ne { def } { pop pop } ifelse \n\
--} forall \n\
--/Encoding ISOLatin1Encoding def \n\
--currentdict end \n\
--/HRomanISO exch definefont pop \n\n\
--/Helvetica-Bold findfont dup length dict begin { \n\
-- 1 index /FID ne { def } { pop pop } ifelse \n\
--} forall \n\
--/Encoding ISOLatin1Encoding def \n\
--currentdict end \n\
--/HBoldISO exch definefont pop \n\n\
--/Helvetica-BoldOblique findfont dup length dict begin { \n\
-- 1 index /FID ne { def } { pop pop } ifelse \n\
--} forall \n\
--/Encoding ISOLatin1Encoding def \n\
--currentdict end \n\
--/HBoldItalicISO exch definefont pop \n\n\
--/Helvetica-Oblique findfont dup length dict begin { \n\
-- 1 index /FID ne { def } { pop pop } ifelse \n\
--} forall \n\
--/Encoding ISOLatin1Encoding def \n\
--currentdict end \n\
--/HItalicISO exch definefont pop \n\n\
--%% \n\
--%% Ideally, before we can draw a line of text, we need to collect all the\n\
--%% words that will be on it, just as I do in my Beest HTML viewer, as well\n\
--%% as character attributes for each word. But for now, this implementation \n\
--%% does not bother. It determines the maximize ascent and descent after\n\
--%% drawing the text, not before. XX\n\
--%% \n\
--%% ----------- Functions ------------\n\
--/updateFont { \n\
-- /f0 null def \n\
-- (Times) fontFamily eq (Times New Roman) fontFamily eq or { \n\
-- bold { \n\
-- italic { /TBoldItalicISO } { /TBoldISO } ifelse \n\
-- } { \n\
-- italic { /TItalicISO } { /TRomanISO } ifelse \n\
-- } \n\
-- ifelse \n\
-- } if \n\
-- (Helvetica) fontFamily eq (Arial) fontFamily eq or { \n\
-- bold { \n\
-- italic { /HBoldItalicISO } { /HBoldISO } ifelse \n\
-- } { \n\
-- italic { /HItalicISO } { /HRomanISO } ifelse \n\
-- } \n\
-- ifelse \n\
-- } if \n\
-- (Courier) fontFamily eq (Courier New) fontFamily eq or { \n\
-- bold { \n\
-- italic { /CBoldItalicISO } { /CBoldISO } ifelse \n\
-- } { \n\
-- italic { /CItalicISO } { /CRomanISO } ifelse \n\
-- } \n\
-- ifelse \n\
-- } if \n\
-- (Symbol) fontFamily eq { \n\
-- bold { \n\
-- italic { /SBoldItalicISO } { /SBoldISO } ifelse \n\
-- } { \n\
-- italic { /SItalicISO } { /SRomanISO } ifelse \n\
-- } \n\
-- ifelse \n\
-- } if \n\n\
-- findfont /f0 exch def  \n\
-- /bboxBottom f0 /FontBBox get 1 get 1000 div fontSize mul -1 mul def \n\
-- /bboxTop    f0 /FontBBox get 3 get 1000 div fontSize mul def \n\
-- f0 fontSize scalefont setfont \n\
-- lineAscent bboxTop lt { /lineAscent bboxTop def } if  \n\
-- lineDescent bboxBottom lt { /lineDescent bboxBottom def } if  \n\
-- /fontAscent bboxTop def \n\
-- /fontDescent bboxBottom def \n\
--} def\n\
--/FS { \n\
-- /fontSize exch def updateFont \n\
--} def \n\
--/F { \n\
-- /fontFamily exch def updateFont \n\
--} def \n\
--/resetX { \n\
-- /x leftMargin def\n\
--} def \n\
--/resetY { \n\
-- /y pageHeight topMargin sub def \n\
--} def \n\
--/BR {  \n\
-- /oldx x def \n\
-- /y y lineAscent lineDescent add sub def  \n\
-- resetX \n\
-- y bottomMargin lt { \n\
-- showpage \n\
-- /didShowPage true \n\
-- resetY \n\
-- } if \n\
-- oldx 0 eq didBR and { /didParSkip true def } if \n\
-- /didBR true def \n\
-- % /lineAscent 0 def \n\
-- % /lineDescent 0 def \n\
--} def \n\
--/P { \n\
-- didParSkip not { BR } if \n\
-- didParSkip not { BR } if \n\
--} \n\
--def \n\
--/acharpath { \n\
-- /acstr exch def pop /acsp exch def \n\
-- newpath  \n\
-- str { \n\
-- /ch exch def \n\
-- 1 string 0 ch put false charpath \n\
-- acsp 0 rmoveto \n\
-- } forall \n\
--} def \n\
--/A { \n\
-- /str exch def \n\
-- /w str stringwidth pop \n\
-- str length intercharSpace mul add \n\
-- def \n\
-- x w add rightLimit ge { BR } if \n\
-- x y moveto \n\
-- outline {                                           \n\
-- shadow {                                    \n\
-- 1 -0.1 0 {                        \n\
-- /offset exch def \n\
-- offset setgray                 \n\
-- x offset 3 mul add y offset 3 mul sub moveto \n\
-- intercharSpace 0 str acharpath \n\
-- %% str false charpath \n\
-- fontSize 30 div setlinewidth stroke \n\
-- } for                               \n\
-- 0 setgray \n\
-- } {                                         \n\
-- intercharSpace 0 str acharpath      \n\
-- %% str false charpath \n\
-- fontSize 30 div setlinewidth stroke \n\
-- } ifelse                                    \n\
-- } {                                                 \n\
-- shadow {                                    \n\
-- 1 -0.1 0 {                        \n\
-- /offset exch def \n\
-- offset setgray                 \n\
-- x offset 3 mul add y offset 3 mul sub moveto \n\
-- intercharSpace 0 str ashow  \n\
-- %% str show \n\
-- } for                               \n\
-- 0 setgray \n\
-- } {                                         \n\
-- intercharSpace 0 str ashow          \n\
-- %% str show \n\
-- } ifelse                                    \n\
-- } ifelse                                            \n\
-- strike { \n\
-- newpath fontSize 20 div setlinewidth \n\
-- x y fontAscent 0.32 mul add dup /y2 exch def moveto \n\
-- x w add y2 lineto stroke \n\
-- } if \n\
-- underline { \n\
-- newpath fontSize 20 div setlinewidth \n\
-- x y fontAscent 0.2 mul sub dup /y2 exch def moveto \n\
-- x w add y2 lineto stroke \n\
-- } if \n\
-- overline { \n\
-- %% I don't think RTF supports this, but it can be used later. \n\
-- newpath fontSize 20 div setlinewidth \n\
-- x y fontAscent 1.2 mul add dup /y2 exch def moveto \n\
-- x w add y2 lineto stroke \n\
-- } if \n\
-- /x x w add def   \n\
-- /didBR false def \n\
-- /didShowPage false def \n\
--} def \n\
--\n\
--%% These are only binary for now \n\
--/X1 { /intercharSpace exch def } def\n\
--/X0 { /intercharSpace 0 def } def\n\
--/O1 { /outline false def } def\n\
--/O0 { /outline false def } def\n\
--/H1 { /shadow true def } def\n\
--/H0 { /shadow false def } def\n\
--/S1 { /strike true def } def\n\
--/S0 { /strike false def } def\n\
--/B1 { /bold true def updateFont } def\n\
--/B0 { /bold false def updateFont } def\n\
--/I1 { /italic true def updateFont } def\n\
--/I0 { /italic false def updateFont } def\n\
--/U1 { /underline true def } def\n\
--/U0 { /underline false def } def\n\
--updateFont \n\
--resetX resetY \n\
--\n\
--"
-+#define PS_START \
-+"%%%%!PS\n"\
-+"%%--------------------------------------------------------------------------\n"\
-+"%% GNU UnRTF, a command-line program to convert RTF documents to other formats.\n"\
-+"%% Copyright (C) 2000,2001 Zachary Thayer Smith\n"\
-+"%%\n"\
-+"%% This program is free software; you can redistribute it and/or modify\n"\
-+"%% it under the terms of the GNU General Public License as published by\n"\
-+"%% the Free Software Foundation; either version 2 of the License, or\n"\
-+"%% (at your option) any later version.\n"\
-+"%%\n"\
-+"%% This program is distributed in the hope that it will be useful,\n"\
-+"%% but WITHOUT ANY WARRANTY; without even the implied warranty of\n"\
-+"%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n"\
-+"%% GNU General Public License for more details.\n"\
-+"%%\n"\
-+"%% You should have received a copy of the GNU General Public License\n"\
-+"%% along with this program; if not, write to the Free Software\n"\
-+"%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\n"\
-+"%%\n"\
-+"%% The author is reachable by electronic mail at [hidden email].\n"\
-+"%%--------------------------------------------------------------------------\n"\
-+"%%%%EndComments \n"\
-+"%%\n"\
-+"%%         --------- Note, this PS code is unfinished -------- \n"\
-+"%%         --------- Note, this PS code is unfinished -------- \n"\
-+"%%         --------- Note, this PS code is unfinished -------- \n"\
-+"%%         --------- Note, this PS code is unfinished -------- \n"\
-+"%%\n"\
-+"%% ----------- Variables ------------\n"\
-+"/fontFamily /Times def\n"\
-+"/fontAscent 0 def %% ascent for current font\n"\
-+"/fontDescent 0 def %% descent for current font\n"\
-+"/lineAscent 0 def \n"\
-+"/lineDescent 0 def \n"\
-+"/pageWidthInches 8.5 def \n"\
-+"/pageHeightInches 11 def \n"\
-+"/leftMargin 20 def \n"\
-+"/rightMargin 20 def \n"\
-+"/topMargin 20 def \n"\
-+"/bottomMargin 20 def \n"\
-+"/DPI 72 def \n"\
-+"/pageWidth pageWidthInches DPI mul def \n"\
-+"/rightLimit pageWidth rightMargin sub def \n"\
-+"/pageHeight pageHeightInches DPI mul def \n"\
-+"/x 0 def \n"\
-+"/y 0 def \n"\
-+"/bold false def \n"\
-+"/italic false def \n"\
-+"/underline false def \n"\
-+"/overline false def \n"\
-+"/intercharSpace 0 def \n"\
-+"/strike false def \n"\
-+"/outline false def \n"\
-+"/shadow false def \n"\
-+"/fontSize 12 def \n"\
-+"/didBR false def \n"\
-+"/didParSkip false def \n"\
-+"/didShowPage false def \n"\
-+"%%------------------------------------------------------\n"\
-+"%% Set up the ISO fonts \n"\
-+"\n"\
-+"%% Times \n"\
-+"%% ----- \n"\
-+"/Times-Roman findfont dup length dict begin { \n"\
-+" 1 index /FID ne { def } { pop pop } ifelse \n"\
-+"} forall \n"\
-+"/Encoding ISOLatin1Encoding def \n"\
-+"currentdict end \n"\
-+"/TRomanISO exch definefont pop \n\n"\
-+"/Times-Bold findfont dup length dict begin { \n"\
-+" 1 index /FID ne { def } { pop pop } ifelse \n"\
-+"} forall \n"\
-+"/Encoding ISOLatin1Encoding def \n"\
-+"currentdict end \n"\
-+"/TBoldISO exch definefont pop \n\n"\
-+"/Times-BoldItalic findfont dup length dict begin { \n"\
-+" 1 index /FID ne { def } { pop pop } ifelse \n"\
-+"} forall \n"\
-+"/Encoding ISOLatin1Encoding def \n"\
-+"currentdict end \n"\
-+"/TBoldItalicISO exch definefont pop \n\n"\
-+"/Times-Italic findfont dup length dict begin { \n"\
-+" 1 index /FID ne { def } { pop pop } ifelse \n"\
-+"} forall \n"\
-+"/Encoding ISOLatin1Encoding def \n"\
-+"currentdict end \n"\
-+"/TItalicISO exch definefont pop \n\n"\
-+"%% Courier \n"\
-+"%% ----- \n"\
-+"/Courier-Roman findfont dup length dict begin { \n"\
-+" 1 index /FID ne { def } { pop pop } ifelse \n"\
-+"} forall \n"\
-+"/Encoding ISOLatin1Encoding def \n"\
-+"currentdict end \n"\
-+"/CRomanISO exch definefont pop \n\n"\
-+"/Courier-Bold findfont dup length dict begin { \n"\
-+" 1 index /FID ne { def } { pop pop } ifelse \n"\
-+"} forall \n"\
-+"/Encoding ISOLatin1Encoding def \n"\
-+"currentdict end \n"\
-+"/CBoldISO exch definefont pop \n\n"\
-+"/Courier-BoldItalic findfont dup length dict begin { \n"\
-+" 1 index /FID ne { def } { pop pop } ifelse \n"\
-+"} forall \n"\
-+"/Encoding ISOLatin1Encoding def \n"\
-+"currentdict end \n"\
-+"/CBoldItalicISO exch definefont pop \n\n"\
-+"/Courier-Italic findfont dup length dict begin { \n"\
-+" 1 index /FID ne { def } { pop pop } ifelse \n"\
-+"} forall \n"\
-+"/Encoding ISOLatin1Encoding def \n"\
-+"currentdict end \n"\
-+"/CItalicISO exch definefont pop \n\n"\
-+"%% Symbol \n"\
-+"%% ----- \n"\
-+"/Symbol-Roman findfont dup length dict begin { \n"\
-+" 1 index /FID ne { def } { pop pop } ifelse \n"\
-+"} forall \n"\
-+"/Encoding ISOLatin1Encoding def \n"\
-+"currentdict end \n"\
-+"/SRomanISO exch definefont pop \n\n"\
-+"/Symbol-Bold findfont dup length dict begin { \n"\
-+" 1 index /FID ne { def } { pop pop } ifelse \n"\
-+"} forall \n"\
-+"/Encoding ISOLatin1Encoding def \n"\
-+"currentdict end \n"\
-+"/SBoldISO exch definefont pop \n\n"\
-+"/Symbol-BoldItalic findfont dup length dict begin { \n"\
-+" 1 index /FID ne { def } { pop pop } ifelse \n"\
-+"} forall \n"\
-+"/Encoding ISOLatin1Encoding def \n"\
-+"currentdict end \n"\
-+"/SBoldItalicISO exch definefont pop \n\n"\
-+"/Symbol-Italic findfont dup length dict begin { \n"\
-+" 1 index /FID ne { def } { pop pop } ifelse \n"\
-+"} forall \n"\
-+"/Encoding ISOLatin1Encoding def \n"\
-+"currentdict end \n"\
-+"/SItalicISO exch definefont pop \n\n"\
-+"%% Helvetica \n"\
-+"%% --------- \n"\
-+"/Helvetica-Roman findfont dup length dict begin { \n"\
-+" 1 index /FID ne { def } { pop pop } ifelse \n"\
-+"} forall \n"\
-+"/Encoding ISOLatin1Encoding def \n"\
-+"currentdict end \n"\
-+"/HRomanISO exch definefont pop \n\n"\
-+"/Helvetica-Bold findfont dup length dict begin { \n"\
-+" 1 index /FID ne { def } { pop pop } ifelse \n"\
-+"} forall \n"\
-+"/Encoding ISOLatin1Encoding def \n"\
-+"currentdict end \n"\
-+"/HBoldISO exch definefont pop \n\n"\
-+"/Helvetica-BoldOblique findfont dup length dict begin { \n"\
-+" 1 index /FID ne { def } { pop pop } ifelse \n"\
-+"} forall \n"\
-+"/Encoding ISOLatin1Encoding def \n"\
-+"currentdict end \n"\
-+"/HBoldItalicISO exch definefont pop \n\n"\
-+"/Helvetica-Oblique findfont dup length dict begin { \n"\
-+" 1 index /FID ne { def } { pop pop } ifelse \n"\
-+"} forall \n"\
-+"/Encoding ISOLatin1Encoding def \n"\
-+"currentdict end \n"\
-+"/HItalicISO exch definefont pop \n\n"\
-+"%% \n"\
-+"%% Ideally, before we can draw a line of text, we need to collect all the\n"\
-+"%% words that will be on it, just as I do in my Beest HTML viewer, as well\n"\
-+"%% as character attributes for each word. But for now, this implementation \n"\
-+"%% does not bother. It determines the maximize ascent and descent after\n"\
-+"%% drawing the text, not before. XX\n"\
-+"%% \n"\
-+"%% ----------- Functions ------------\n"\
-+"/updateFont { \n"\
-+" /f0 null def \n"\
-+" (Times) fontFamily eq (Times New Roman) fontFamily eq or { \n"\
-+" bold { \n"\
-+" italic { /TBoldItalicISO } { /TBoldISO } ifelse \n"\
-+" } { \n"\
-+" italic { /TItalicISO } { /TRomanISO } ifelse \n"\
-+" } \n"\
-+" ifelse \n"\
-+" } if \n"\
-+" (Helvetica) fontFamily eq (Arial) fontFamily eq or { \n"\
-+" bold { \n"\
-+" italic { /HBoldItalicISO } { /HBoldISO } ifelse \n"\
-+" } { \n"\
-+" italic { /HItalicISO } { /HRomanISO } ifelse \n"\
-+" } \n"\
-+" ifelse \n"\
-+" } if \n"\
-+" (Courier) fontFamily eq (Courier New) fontFamily eq or { \n"\
-+" bold { \n"\
-+" italic { /CBoldItalicISO } { /CBoldISO } ifelse \n"\
-+" } { \n"\
-+" italic { /CItalicISO } { /CRomanISO } ifelse \n"\
-+" } \n"\
-+" ifelse \n"\
-+" } if \n"\
-+" (Symbol) fontFamily eq { \n"\
-+" bold { \n"\
-+" italic { /SBoldItalicISO } { /SBoldISO } ifelse \n"\
-+" } { \n"\
-+" italic { /SItalicISO } { /SRomanISO } ifelse \n"\
-+" } \n"\
-+" ifelse \n"\
-+" } if \n\n"\
-+" findfont /f0 exch def  \n"\
-+" /bboxBottom f0 /FontBBox get 1 get 1000 div fontSize mul -1 mul def \n"\
-+" /bboxTop    f0 /FontBBox get 3 get 1000 div fontSize mul def \n"\
-+" f0 fontSize scalefont setfont \n"\
-+" lineAscent bboxTop lt { /lineAscent bboxTop def } if  \n"\
-+" lineDescent bboxBottom lt { /lineDescent bboxBottom def } if  \n"\
-+" /fontAscent bboxTop def \n"\
-+" /fontDescent bboxBottom def \n"\
-+"} def\n"\
-+"/FS { \n"\
-+" /fontSize exch def updateFont \n"\
-+"} def \n"\
-+"/F { \n"\
-+" /fontFamily exch def updateFont \n"\
-+"} def \n"\
-+"/resetX { \n"\
-+" /x leftMargin def\n"\
-+"} def \n"\
-+"/resetY { \n"\
-+" /y pageHeight topMargin sub def \n"\
-+"} def \n"\
-+"/BR {  \n"\
-+" /oldx x def \n"\
-+" /y y lineAscent lineDescent add sub def  \n"\
-+" resetX \n"\
-+" y bottomMargin lt { \n"\
-+" showpage \n"\
-+" /didShowPage true \n"\
-+" resetY \n"\
-+" } if \n"\
-+" oldx 0 eq didBR and { /didParSkip true def } if \n"\
-+" /didBR true def \n"\
-+" % /lineAscent 0 def \n"\
-+" % /lineDescent 0 def \n"\
-+"} def \n"\
-+"/P { \n"\
-+" didParSkip not { BR } if \n"\
-+" didParSkip not { BR } if \n"\
-+"} \n"\
-+"def \n"\
-+"/acharpath { \n"\
-+" /acstr exch def pop /acsp exch def \n"\
-+" newpath  \n"\
-+" str { \n"\
-+" /ch exch def \n"\
-+" 1 string 0 ch put false charpath \n"\
-+" acsp 0 rmoveto \n"\
-+" } forall \n"\
-+"} def \n"\
-+"/A { \n"\
-+" /str exch def \n"\
-+" /w str stringwidth pop \n"\
-+" str length intercharSpace mul add \n"\
-+" def \n"\
-+" x w add rightLimit ge { BR } if \n"\
-+" x y moveto \n"\
-+" outline {                                           \n"\
-+" shadow {                                    \n"\
-+" 1 -0.1 0 {                        \n"\
-+" /offset exch def \n"\
-+" offset setgray                 \n"\
-+" x offset 3 mul add y offset 3 mul sub moveto \n"\
-+" intercharSpace 0 str acharpath \n"\
-+" %% str false charpath \n"\
-+" fontSize 30 div setlinewidth stroke \n"\
-+" } for                               \n"\
-+" 0 setgray \n"\
-+" } {                                         \n"\
-+" intercharSpace 0 str acharpath      \n"\
-+" %% str false charpath \n"\
-+" fontSize 30 div setlinewidth stroke \n"\
-+" } ifelse                                    \n"\
-+" } {                                                 \n"\
-+" shadow {                                    \n"\
-+" 1 -0.1 0 {                        \n"\
-+" /offset exch def \n"\
-+" offset setgray                 \n"\
-+" x offset 3 mul add y offset 3 mul sub moveto \n"\
-+" intercharSpace 0 str ashow  \n"\
-+" %% str show \n"\
-+" } for                               \n"\
-+" 0 setgray \n"\
-+" } {                                         \n"\
-+" intercharSpace 0 str ashow          \n"\
-+" %% str show \n"\
-+" } ifelse                                    \n"\
-+" } ifelse                                            \n"\
-+" strike { \n"\
-+" newpath fontSize 20 div setlinewidth \n"\
-+" x y fontAscent 0.32 mul add dup /y2 exch def moveto \n"\
-+" x w add y2 lineto stroke \n"\
-+" } if \n"\
-+" underline { \n"\
-+" newpath fontSize 20 div setlinewidth \n"\
-+" x y fontAscent 0.2 mul sub dup /y2 exch def moveto \n"\
-+" x w add y2 lineto stroke \n"\
-+" } if \n"\
-+" overline { \n"\
-+" %% I don't think RTF supports this, but it can be used later. \n"\
-+" newpath fontSize 20 div setlinewidth \n"\
-+" x y fontAscent 1.2 mul add dup /y2 exch def moveto \n"\
-+" x w add y2 lineto stroke \n"\
-+" } if \n"\
-+" /x x w add def   \n"\
-+" /didBR false def \n"\
-+" /didShowPage false def \n"\
-+"} def \n"\
-+"\n"\
-+"%% These are only binary for now \n"\
-+"/X1 { /intercharSpace exch def } def\n"\
-+"/X0 { /intercharSpace 0 def } def\n"\
-+"/O1 { /outline false def } def\n"\
-+"/O0 { /outline false def } def\n"\
-+"/H1 { /shadow true def } def\n"\
-+"/H0 { /shadow false def } def\n"\
-+"/S1 { /strike true def } def\n"\
-+"/S0 { /strike false def } def\n"\
-+"/B1 { /bold true def updateFont } def\n"\
-+"/B0 { /bold false def updateFont } def\n"\
-+"/I1 { /italic true def updateFont } def\n"\
-+"/I0 { /italic false def updateFont } def\n"\
-+"/U1 { /underline true def } def\n"\
-+"/U0 { /underline false def } def\n"\
-+"updateFont \n"\
-+"resetX resetY \n"\
-+"\n"
-
-
-
Index: pkg/PLIST
===================================================================
RCS file: /cvs/ports/textproc/unrtf/pkg/PLIST,v
retrieving revision 1.2
diff -u -p -r1.2 PLIST
--- pkg/PLIST 15 Sep 2004 18:44:08 -0000 1.2
+++ pkg/PLIST 10 Jun 2011 11:05:46 -0000
@@ -1,5 +1,10 @@
 @comment $OpenBSD: PLIST,v 1.2 2004/09/15 18:44:08 espie Exp $
-bin/unrtf
+@bin bin/unrtf
 @man man/man1/unrtf.1
-share/doc/unrtf/
-share/doc/unrtf/unrtf.html
+share/unrtf/
+share/unrtf/SYMBOL.charmap
+share/unrtf/html.conf
+share/unrtf/latex.conf
+share/unrtf/rtf.conf
+share/unrtf/text.conf
+share/unrtf/vt.conf

Reply | Threaded
Open this post in threaded view
|

Re: unrtf segmentation fault

Marco Spiga-2
In reply to this post by Stuart Henderson
Dear Stuart.

Your answer is very complicated for my skills :-(.
I found the problem by making a random test and not for personal use, therefore
I have request to solve it not for me (I use unrtf on linux) but for OpenBSD
comunity.
Please Stuard tell me if I did right or wrong I have to highlight it.
I'am sorry to have send incomplete mail to uncorrect address (bugs@openbsd),
but I have send it several days later that I have found problem, from another
computer and no other informations.

If my action was not correct I apologize.

Thank for your response.

Marco



--
===============================================================================
                Nel caso la mail sia stata ricevuta per errore
        cortesemente avvisate il mittente e cancellatela immediatamente.

                                Grazie.
===============================================================================

        Meglio coltivare GNU/Linux...... tanto Windows si pianta da solo!!!!

Reply | Threaded
Open this post in threaded view
|

Re: unrtf segmentation fault

Stuart Henderson
On 2011/06/13 19:22, Marco wrote:
> Your answer is very complicated for my skills :-(.

ok, a quick summary:

unrtf is buggy.

those bugs will affect all OS, but are most clearly visible on OpenBSD.