From 3bea3aed15c41afc1ccc783c8d9a022ca478d8ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20N=C3=A9meth?= Date: Mon, 18 Mar 2013 10:49:03 +0000 Subject: [PATCH] hjn_hyphen_load_file patch for sandboxing by Pawel Hajdan --- ChangeLog | 6 ++++++ Makefile.am | 2 +- Makefile.in | 2 +- hyphen.c | 22 +++++++++++++++------- hyphen.h | 1 + 5 files changed, 24 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 057d91a..acb4bc0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2013-03-18 László Németh : + * Makefile.am, Makefile.in: set -version-info + +2013-03-12 Paweł Hajdan : + * hyphen.h, hyphen.c: add hnj_hyphen_load_file() for sandboxing + 2012-09-13 László Németh : * hyphen.c: fdo#43931: removing hard hyphen hyphenation for LibreOffice diff --git a/Makefile.am b/Makefile.am index 7747416..a62a0e1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,7 +2,7 @@ SUBDIRS= doc tests lib_LTLIBRARIES = libhyphen.la libhyphen_la_SOURCES = hnjalloc.c hyphen.c -libhyphen_la_LDFLAGS = -version-info 2:1:2 +libhyphen_la_LDFLAGS = -version-info 3:0:3 include_HEADERS = hyphen.h noinst_HEADERS = hnjalloc.h diff --git a/Makefile.in b/Makefile.in index 2913170..3907f37 100644 --- a/Makefile.in +++ b/Makefile.in @@ -288,7 +288,7 @@ top_srcdir = @top_srcdir@ SUBDIRS = doc tests lib_LTLIBRARIES = libhyphen.la libhyphen_la_SOURCES = hnjalloc.c hyphen.c -libhyphen_la_LDFLAGS = -version-info 2:1:2 +libhyphen_la_LDFLAGS = -version-info 3:0:3 include_HEADERS = hyphen.h noinst_HEADERS = hnjalloc.h substrings_SOURCES = substrings.c diff --git a/hyphen.c b/hyphen.c index 6b1d826..13a81a5 100644 --- a/hyphen.c +++ b/hyphen.c @@ -373,20 +373,29 @@ void hnj_hyphen_load_line(char * buf, HyphenDict * dict, HashTab * hashtab) { HyphenDict * hnj_hyphen_load (const char *fn) +{ + HyphenDict *result; + FILE *f; + f = fopen (fn, "r"); + if (f == NULL) + return NULL; + + result = hnj_hyphen_load_file(f); + + fclose(f); + return result; +} + +HyphenDict * +hnj_hyphen_load_file (FILE *f) { HyphenDict *dict[2]; HashTab *hashtab; - FILE *f; char buf[MAX_CHARS]; int nextlevel = 0; int i, j, k; HashEntry *e; int state_num = 0; - - f = fopen (fn, "r"); - if (f == NULL) - return NULL; - // loading one or two dictionaries (separated by NEXTLEVEL keyword) for (k = 0; k < 2; k++) { hashtab = hnj_hash_new (); @@ -497,7 +506,6 @@ for (k = 0; k < 2; k++) { #endif state_num = 0; } - fclose(f); if (nextlevel) dict[0]->nextlevel = dict[1]; else { dict[1] -> nextlevel = dict[0]; diff --git a/hyphen.h b/hyphen.h index 1b91ddc..9aa057e 100644 --- a/hyphen.h +++ b/hyphen.h @@ -94,6 +94,7 @@ struct _HyphenTrans { }; HyphenDict *hnj_hyphen_load (const char *fn); +HyphenDict *hnj_hyphen_load_file (FILE *f); void hnj_hyphen_free (HyphenDict *dict); /* obsolete, use hnj_hyphen_hyphenate2() or *hyphenate3() functions) */