--- xjdic-24.orig/Makefile +++ xjdic-24/Makefile @@ -55,7 +55,7 @@ #LIBS= -lsocket -lnsl # CC=gcc -g -all: xjdic_sa xjdic_cl xjdserver xjdxgen exjdxgen +all: xjdic_sa xjdic_cl xjdserver xjdxgen exjdxgen xjdrad client: xjdic_cl server: xjdserver stand: xjdic_sa @@ -123,11 +123,17 @@ xjdserver.o: xjdserver.c $(CC) -c $(SVCFLAGS) xjdserver.c $(SVOBJECTS): xjdic.h + +# xjdrad +xjdrad: xjdrad.c + $(CC) $^ -o $@ + + # clean: rm -f *.o realclean: clean - rm -f xjdic_sa xjdic_cl xjdserver xjdxgen exjdxgen + rm -f xjdic_sa xjdic_cl xjdserver xjdxgen exjdxgen xjdrad # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by --- xjdic-24.orig/debian/.xjdicrc.skel +++ xjdic-24/debian/.xjdicrc.skel @@ -0,0 +1,34 @@ +# +# Sample .xjdicrc file +# +# (remove comments from lines below if you want to activate the +# option) +# +# server (default is localhost) +# server daneel.dgs.monash.edu.au +dicdir /home/jwb/nihongo/dics +kdicfile kanjidic_b +# note that I use "kanjidic_b", because I have joined the kanjidic & +# kanjd212 files +# dicfile (default is edict alone) +dicfile edict +dicfile jddict +dicfile compdic +#dicfile enamdict +# kdnosho (no default) +kdnoshow YELUQMKZ +# filt (no defaults) +# +# I don't use these filters, now that names have been moved +# to the ENAMDICT file +#filt 0 2 off "Exclude proper names" (pl, (pn pl) pn) +#filt 1 1 off "Exclude all place names" (pl, pl) +#filt 2 1 off "Exclude all person names" (pn pn) +#filt 3 0 off "Show only person names" (pn pn) +#filt 4 0 off "Show only place names" (pl, pl) +#filt 5 0 off "Show only place & person names" (pl, (pn pl) pn) +# extfile (default is edictext) +#extfile edictexx +# exlist (no default excluded words for xjdxgen) +exlist abbr col vul vulg then and conj int pron pref suf syn ant from +exlist adv adj hon hum pol jap japanese --- xjdic-24.orig/debian/README.Debian +++ xjdic-24/debian/README.Debian @@ -0,0 +1,30 @@ +xjdic for Debian +---------------------- + +* There are 3 versions of kjdic program + + stand-alone type: xjdic_sa + client type: xjdic_cl + server type: xjserver + + xjdic is an alias for xjdic_sa. + +* The default directory of dictionaries in edict formats is + /usr/share/edict + and one for index files is + /var/lib/xjdic. + +* Index files are generated at installing time. + +* When some dictionary is updated, you can remake its index file by + + /usr/sbin/xjdicconfig DICTIONARY_NAME + +* or rebuild all index files by + + /usr/sbin/xjdicconfig + +* /usr/share/doc/xjdic/dot.xjdicrc is a sample ~/.xjdicrc file + (configuration file). + + -- Hayao Nakahara , Tue, 19 Oct 1999 01:18:34 +0900 --- xjdic-24.orig/debian/changelog +++ xjdic-24/debian/changelog @@ -0,0 +1,151 @@ +xjdic (24-10build1) bionic; urgency=high + + * No change rebuild to pick up -fPIE compiler default + + -- Balint Reczey Tue, 03 Apr 2018 12:52:31 +0000 + +xjdic (24-10) unstable; urgency=medium + + * Fixed buffer overrruns bugs in xjdfrontend.c. Closes: #786844 + * Fixed the 2 Mahyem bugs. Closes: #716509, #716514 + But there are waaaay more bugs left in the code, a complete rewrite of + xjdic would be more simple... + * Fixed the clang compile bugs. Closes: #740227, #748419 + + -- Ludovic Drolez Wed, 17 Jun 2015 21:16:03 +0200 + +xjdic (24-9) unstable; urgency=medium + + * Fixed: Hurd patch broke tty ioctl(). Closes: #673341 + * Fixed: xjdxgen crashes with exit status 139. Closes: #716516 + * Fixed bug in xjdcomm.c. Closes: #716513 #716515 + * hardening with dpkg-buildflags + + -- Ludovic Drolez Mon, 10 Feb 2014 20:44:51 +0100 + +xjdic (24-8) unstable; urgency=low + + * xjdicconfig man page belongs to section 8. Closes: #512452 + * fixed a FTBFS on hurd-i386. Closes: #670884 + * fixed the "Reply overrun". Closes: #475836 + + -- Ludovic Drolez Tue, 08 May 2012 18:22:22 +0200 + +xjdic (24-7) unstable; urgency=medium + + * Fixed the FTBFS on GNU/kFreeBSD. Urgency set to medium. Closes: #414208 + * Added xjdrad. Closes: #438831 + * Bad usage of termios constants was breaking xjdic on PowerPC. + Closes: #258111 + + -- Ludovic Drolez Mon, 12 Mar 2007 18:32:07 +0100 + +xjdic (24-6) unstable; urgency=low + + * fix for a segfault on ia64. Closes: #325787 + + -- Ludovic Drolez Thu, 1 Sep 2005 10:43:02 +0200 + +xjdic (24-5) unstable; urgency=low + + * set VMAX to 600 to avoid verb data overflow. Closes: #253995 + + -- Ludovic Drolez Fri, 1 Apr 2005 22:32:45 +0200 + +xjdic (24-4) unstable; urgency=low + + * Debian watch file added + * Applied a patch for amd64. Closes: Bug#280315. + + -- Ludovic Drolez Sat, 13 Nov 2004 22:06:26 +0200 + +xjdic (24-3) unstable; urgency=low + + * Symlink to GNU license corrected. Closes: #204782. + + -- Ludovic Drolez Mon, 11 Aug 2003 19:56:37 +0200 + +xjdic (24-2) unstable; urgency=low + + * Only depends on DFSG compliant packages, so now moved in free. + * The GNU license is now displayed correctly with the '!' key + + -- Ludovic Drolez Sat, 26 Jul 2003 23:23:27 +0200 + +xjdic (24-1) unstable; urgency=low + + * New upstream release + + -- Ludovic Drolez Sun, 22 Jun 2003 23:17:05 +0200 + +xjdic (23-5) unstable; urgency=low + + * Segfault bug fixed thanks to Jim Breen. Closes: Bug#180836 + + -- Ludovic Drolez Thu, 22 May 2003 23:53:12 +0200 + +xjdic (23-4) unstable; urgency=low + + * New maintainer. Closes: Bug#192688 + * Take into account DEB_BUILD_OPTIONS + * More dictionaries in /usr/sbin/xjdicconfig. Closes: Bug#141321 + * Exact match option for .xjdicrc. Closes: Bug#152105 + + -- Ludovic Drolez Wed, 21 May 2003 15:40:31 +0200 + +xjdic (23-3) unstable; urgency=low + + * Put edict and kanjidict to depends list. (closes: #88117) + + -- Hayao Nakahara Thu, 27 Dec 2001 04:50:09 +0900 + +xjdic (23-2) unstable; urgency=low + + * Initial Debian Release. + + -- Hayao Nakahara Tue, 19 Oct 1999 01:18:34 +0900 + +xjdic (23-1) unstable; urgency=low + + * new upstream source. + + -- Hayao Nakahara Sun, 16 May 1999 16:56:53 +0900 + +xjdic (22-5) frozen-jp unstable-jp; urgency=low + + * changed the dictionary directory to /var/lib/xjdic. + * added xjdicconfig. + + -- Hayao Nakahara Thu, 26 Nov 1998 04:53:58 +0900 + +xjdic (22-4) contrib; urgency=low + + * compiled with libc6. + * applied some of patches by Katsuya Nagai (katsuya@kcn.or.jp). + * moved dictionary directory to /usr/share/dict. + * fixed xjdxgen.c. + * fixed bugs: JP/134, JP/150. + * fixed postinst. + + -- Hayao Nakahara Thu, 21 May 1998 00:57:41 +0900 + +xjdic (22-3) contrib-jp; urgency=low + + * fixed the location of _xjdicrc.expamle. + * put edict to Depends. + + -- Hayao Nakahara Tue, 22 Apr 1997 21:00:26 +0900 + +xjdic (22-2) unstable; urgency=low + + * Fixed dependency. + + -- Hayao Nakahara Thu, 30 Jan 1997 15:33:24 +0900 + +xjdic (22-1) unstable; urgency=low + + * Initial Release. + + -- Hayao Nakahara Sat, 16 Nov 1996 19:49:01 +0900 + + --- xjdic-24.orig/debian/compat +++ xjdic-24/debian/compat @@ -0,0 +1 @@ +5 --- xjdic-24.orig/debian/control +++ xjdic-24/debian/control @@ -0,0 +1,17 @@ +Source: xjdic +Section: text +Priority: optional +Maintainer: Ubuntu Developers +XSBC-Original-Maintainer: Ludovic Drolez +Build-Depends: debhelper (>> 3.0.0) +Standards-Version: 3.9.6 + +Package: xjdic +Architecture: any +Depends: ${shlibs:Depends}, edict, kanjidic, ${misc:Depends} +Recommends: kterm +Description: Japanese-English dictionary search program + XJDIC is an electronic Japanese-English dictionary program designed to + operate in the X11 window environment. In particular, it must run in an + "xterm" environment which has Japanese language support such as provided by + "kterm" etc. --- xjdic-24.orig/debian/copyright +++ xjdic-24/debian/copyright @@ -0,0 +1,21 @@ +This package was debianized by Hayao Nakahara on +Tue, 19 Oct 1999 01:18:34 +0900. + +It was downloaded from ftp://ftp.cc.monash.edu.au/pub/nihongo/xjdic23.tar.gz + +Upstream Author: Jim Breen + +Copyright: + +Copyright: J.W. Breen - 2003 + +The source code and documentation of XJDIC are hereby released under the +terms of the GNU General Public License (GPL). All usage of this program is +at the user's risk, and there is no warranty on its performance. Copies may +be distributed by any means which conforms to the terms of the GPL. + +On Debian GNU/Linux systems you can find a cpoy of the GPL in +/usr/share/common-licenses/GPL. + +XJDIC heavily depends edict package which is in non-free, so XJDIC is +in a contrib part in Debian. --- xjdic-24.orig/debian/dirs +++ xjdic-24/debian/dirs @@ -0,0 +1,6 @@ +usr/bin +usr/sbin +var/lib/xjdic +usr/share/man/man1 +usr/share/man/man8 +usr/share/doc/xjdic --- xjdic-24.orig/debian/docs +++ xjdic-24/debian/docs @@ -0,0 +1,4 @@ +xjdic22.WHATSNEW +xjdic23.WHATSNEW +xjdic24.WHATSNEW +xjdic24.txt --- xjdic-24.orig/debian/links +++ xjdic-24/debian/links @@ -0,0 +1,5 @@ +usr/share/man/man1/xjdic.1 usr/share/man/man1/xjdic_cl.1 +usr/share/man/man1/xjdic.1 usr/share/man/man1/xjdic_sa.1 +usr/share/man/man1/xjdic.1 usr/share/man/man1/xjdserver.1 +usr/share/man/man1/xjdic.1 usr/share/man/man1/xjdxgen.1 +usr/share/man/man1/xjdic.1 usr/share/man/man1/exjdxgen.1 --- xjdic-24.orig/debian/postinst +++ xjdic-24/debian/postinst @@ -0,0 +1,47 @@ +#! /bin/sh +# postinst script for xjdic +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `configure' +# * `abort-upgrade' +# * `abort-remove' `in-favour' +# +# * `abort-deconfigure' `in-favour' +# `removing' +# +# for details, see /usr/doc/packaging-manual/ +# +# quoting from the policy: +# Any necessary prompting should almost always be confined to the +# post-installation script, and should be protected with a conditional +# so that unnecessary prompting doesn't happen if a package's +# installation fails and the `postinst' is called with `abort-upgrade', +# `abort-remove' or `abort-deconfigure'. + +case "$1" in + configure) + xjdicconfig + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 0 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 + + --- xjdic-24.orig/debian/prerm +++ xjdic-24/debian/prerm @@ -0,0 +1,43 @@ +#! /bin/sh +# prerm script for xjdic +# +# see: dh_installdeb(1) + +DICTDIR=/var/lib/xjdic + +set -e + +# summary of how this script can be called: +# * `remove' +# * `upgrade' +# * `failed-upgrade' +# * `remove' `in-favour' +# * `deconfigure' `in-favour' +# `removing' +# +# for details, see /usr/doc/packaging-manual/ + +case "$1" in + remove) + cd $DICTDIR + rm -f * + ;; + remove|upgrade|deconfigure) +# install-info --quiet --remove /usr/info/xjdic.info.gz + ;; + failed-upgrade) + ;; + *) + echo "prerm called with unknown argument \`$1'" >&2 + exit 0 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 + + --- xjdic-24.orig/debian/rules +++ xjdic-24/debian/rules @@ -0,0 +1,120 @@ +#!/usr/bin/make -f +# Sample debian/rules that uses debhelper. +# GNU copyright 1997 to 1999 by Joey Hess. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +CPPFLAGS:=$(shell dpkg-buildflags --get CPPFLAGS) +CFLAGS:=$(shell dpkg-buildflags --get CFLAGS) +CXXFLAGS:=$(shell dpkg-buildflags --get CXXFLAGS) +LDFLAGS:=$(shell dpkg-buildflags --get LDFLAGS) + +#export CFLAGS := -Wall -g +ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) + CFLAGS += -O0 +else + CFLAGS += -O3 +endif + +DH_STRIP=dh_strip +ifneq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) + DH_STRIP=true +endif + +configure: configure-stamp +configure-stamp: + dh_testdir + # Add here commands to configure the package. + + + touch configure-stamp + +build-arch: build +build-indep: build + +build: configure-stamp build-stamp +build-stamp: + dh_testdir + + # Add here commands to compile the package. + $(MAKE) CC="gcc $(CPPFLAGS) $(CFLAGS) $(LDFLAGS)" + #/usr/bin/docbook-to-man debian/test-s.sgml > test-s.1 + cp -f xjdic24.inf xjdic24.txt + touch build-stamp + +clean: + dh_testdir + dh_testroot + rm -f build-stamp configure-stamp + # Add here commands to clean up after the build process. + $(MAKE) realclean + rm -f xjdic24.txt + + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + # Add here commands to install the package into debian/test-s. +# $(MAKE) install DESTDIR=$(CURDIR)/debian/test-s + install -m 755 exjdxgen debian/xjdic/usr/bin/exjdxgen + install -m 755 xjdic_cl debian/xjdic/usr/bin/xjdic_cl + install -m 755 xjdic_sa debian/xjdic/usr/bin/xjdic_sa + ln -sf xjdic_sa debian/xjdic/usr/bin/xjdic + install -m 755 xjdserver debian/xjdic/usr/bin/xjdserver + install -m 755 xjdxgen debian/xjdic/usr/bin/xjdxgen + install -m 755 xjdrad debian/xjdic/usr/bin/xjdrad + install -m 755 debian/xjdicconfig \ + debian/xjdic/usr/sbin/xjdicconfig + install -m 644 debian/.xjdicrc.skel \ + debian/xjdic/usr/share/doc/xjdic/dot.xjdicrc + install -m 644 xjdic.1 debian/xjdic/usr/share/man/man1/xjdic.1 + install -m 644 debian/xjdicconfig.man \ + debian/xjdic/usr/share/man/man8/xjdicconfig.8 + install -m 644 kanjstroke debian/xjdic/var/lib/xjdic + install -m 644 radicals.tm debian/xjdic/var/lib/xjdic + install -m 644 radkfile debian/xjdic/var/lib/xjdic + install -m 644 romkana.cnv debian/xjdic/var/lib/xjdic + install -m 644 vconj debian/xjdic/var/lib/xjdic + ln -sf /usr/share/common-licenses/GPL debian/xjdic/var/lib/xjdic/gnu_licence + +# Build architecture-independent files here. +binary-indep: build install +# We have nothing to do by default. + +# Build architecture-dependent files here. +binary-arch: build install + dh_testdir + dh_testroot +# dh_installdebconf + dh_installdocs + dh_installexamples + dh_installmenu +# dh_installlogrotate +# dh_installemacsen +# dh_installpam +# dh_installmime +# dh_installinit + dh_installcron + dh_installman + dh_installinfo +# dh_undocumented + dh_installchangelogs + dh_link + $(DH_STRIP) + dh_compress + dh_fixperms +# dh_makeshlibs + dh_installdeb +# dh_perl + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install configure --- xjdic-24.orig/debian/watch +++ xjdic-24/debian/watch @@ -0,0 +1,2 @@ +version=2 +ftp://ftp.cc.monash.edu.au/pub/nihongo/xjdic([\d\.]*)\.tgz debian uupdate --- xjdic-24.orig/debian/xjdicconfig +++ xjdic-24/debian/xjdicconfig @@ -0,0 +1,30 @@ +#!/bin/sh + +DICTS="compdic edict enamdict findic geodic kanjidic lifscdic lingdic \ +j_places engscidic jddicy mktdic finmtkdic panpdic aviation concrete \ +lawdic stardic" + +DICTS212="edicth kanjd212" +DICDIR=/var/lib/xjdic +EDICT=/usr/share/edict + +case $# in +0) +;; +*) DICTS=$@ +;; +esac + +cd $DICDIR +for d in $DICTS +do + rm -f $d $d.xjdx + if [ -f $EDICT/$d ]; then + ln -sf $EDICT/$d . + elif [ -f $EDICT/$d.gz ]; then + zcat $EDICT/$d.gz > $d + else + continue + fi + xjdxgen $d +done --- xjdic-24.orig/debian/xjdicconfig.man +++ xjdic-24/debian/xjdicconfig.man @@ -0,0 +1,33 @@ +.TH XJDICCONFIG 8 +.\" NAME should be all caps, SECTION should be 1-8, maybe w/ subsection +.\" other parms are allowed: see man(7), man(1) +.SH NAME +xjdicconfig \- program to create index files for xjdic program. +.SH SYNOPSIS +.B xjdicconfig +.br +.B xjdicconfig +.I "dict ..." +.SH "DESCRIPTION" +.BR xjdicconfig +make index files for xjdic programs. +If arguments are given, +.BR xjdicconfig +make index files of dictionaries +specified by arguments. +Without arguments, +.BR xjdicconfig +make index files all available dictionaries. +.SH FILES +.TP +.I /usr/share/edict +Directory for dictionaries in +.I edict +format. +.TP +.I /var/lib/xjdic +Directory for index files. +Symbolic links to dictionries must exists in this directory. +.SH AUTHOR +This manual page was written by Hayao Nakahara , +for the Debian GNU/Linux system (but may be used by others). --- xjdic-24.orig/exjdxgen.c +++ xjdic-24/exjdxgen.c @@ -66,9 +66,7 @@ } /*====function to Load Dictionary and load/create index table=======*/ -main(argc,argv) -int argc; -unsigned char **argv; +main(int argc, char **argv) { FILE *fp,*fopen(); unsigned long schi,diclen,indlen; --- xjdic-24.orig/xjdclient.c +++ xjdic-24/xjdclient.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -40,7 +41,6 @@ #define CVERBOSE 0 int chk_cnt=0; -extern int errno; unsigned char host[51] = {"localhost"}; unsigned char yn[2]; unsigned int portno = XJ_PORTNO; --- xjdic-24.orig/xjdcomm.c +++ xjdic-24/xjdcomm.c @@ -232,6 +232,7 @@ while(fgets(rcstr,79,fm) != NULL) { rcwd = (unsigned char *)strtok(rcstr," \t"); + if (rcwd == NULL) continue; /* Debian fix for bug #716515 */ /* dicdir works for all modes */ if( stringcomp((unsigned char *)"dicdir",rcwd) == 0) { --- xjdic-24.orig/xjdfrontend.c +++ xjdic-24/xjdfrontend.c @@ -21,11 +21,15 @@ #include #include #include +#ifdef __GNU__ +#include +#endif #include #include #include #include #include +#include #include "xjdic.h" /* Paul Burchard supplied a patch to provide BSD compatibility for xjdic @@ -33,10 +37,14 @@ order to enable this, people should compile with the option -D__STRICT_BSD___ . */ +#if defined(__FreeBSD_kernel__) +#define __STRICT_BSD__ +#endif + #ifdef __STRICT_BSD__ #include #else -#ifdef __POSIX__ +#if defined(__POSIX__) || defined(__GNU__) #include #else #include @@ -55,6 +63,8 @@ #ifdef __STRICT_BSD__ static struct sgttyb orig,new; +#elif defined(__GNU__) +static struct termios orig,new; #else static struct termio orig,new; #endif @@ -98,7 +108,7 @@ unsigned char kmodes[2][10] = {"ON","OFF"}; unsigned char kmodes_r[2][10] = {"OFF","ON"}; unsigned long chline,chpos,it; -unsigned char strfilt[10],tempout[80]; +unsigned char strfilt[10],tempout[256]; unsigned char KSname[50] = {"kanjstroke"}; unsigned char RKname[50] = {"radkfile"}; unsigned char Rname[50] = {"radicals.tm"}; @@ -115,7 +125,7 @@ unsigned char sver[] = {SVER}; unsigned char fbuff[512],KLine[KFBUFFSIZE],karray[KANJARRAYSIZE][5]; unsigned char LogLine[200]; -unsigned char ksch[50],ktarg[50]; +unsigned char ksch[256],ktarg[256]; /* The following Help table has "~" to force spaces */ unsigned char Help[40][81] = { "\n~~~~~~~~~~~~~~~~~~XJDIC USAGE SUMMARY ", @@ -223,6 +233,7 @@ void NewWinSize(); int kcmp (unsigned char *t1, unsigned char *t2); unsigned char *DicName(int dn); +size_t strlcat(dst, src, siz); /*====== end of prototypes==================================================*/ @@ -242,10 +253,19 @@ new.sg_flags |= CBREAK; new.sg_flags &= ~ECHO; ioctl(0, TIOCSETP, &new); #else +#ifdef __GNU__ + tcgetattr(0, &orig); tcgetattr(0, &new); +#else ioctl(0, TCGETA, &orig); ioctl(0, TCGETA, &new); +#endif new.c_lflag &= ~ICANON; new.c_lflag &= ~ISIG; new.c_lflag &= ~ECHO; new.c_lflag &= ~IXON; - new.c_cc[4] = 1; new.c_cc[5] = 0; ioctl(0, TCSETA, &new); + new.c_cc[VMIN] = 1; new.c_cc[VTIME] = 0; +#ifdef __GNU__ + tcsetattr(0, TCSANOW, &new); +#else + ioctl(0, TCSETA, &new); +#endif #endif myi_status=IOCTL_RAW; } @@ -256,6 +276,8 @@ { #ifdef __STRICT_BSD__ ioctl(0, TIOCSETP, &orig); +#elif defined(__GNU__) + tcsetattr(0, TCSANOW, &orig); #else ioctl(0, TCSETA, &orig); #endif @@ -440,7 +462,7 @@ { ksch[is-1] = '\0'; is--; - sprintf(tempout,"\r \r%sROMAJI ENTRY:%s %s%s",RVon,RVoff,ktarg,ksch+ksp); + snprintf(tempout,sizeof(tempout),"\r \r%sROMAJI ENTRY:%s %s%s",RVon,RVoff,ktarg,ksch+ksp); KOut(tempout); continue; } @@ -449,7 +471,7 @@ if (strlen(ktarg) != 0) /* kana mode - back over a kana */ { ktarg[strlen(ktarg)-2] = '\0'; - sprintf(tempout,"\r \r%sROMAJI ENTRY:%s %s%s",RVon,RVoff,ktarg,ksch+ksp); + snprintf(tempout,sizeof(tempout),"\r \r%sROMAJI ENTRY:%s %s%s",RVon,RVoff,ktarg,ksch+ksp); KOut(tempout); continue; } @@ -460,7 +482,7 @@ ksch[is] = c | 0x20; ksch[is+1] = '\0'; is++; - sprintf(tempout,"\r \r%sROMAJI ENTRY:%s %s%s",RVon,RVoff,ktarg,ksch+ksp); + snprintf(tempout,sizeof(tempout),"\r \r%sROMAJI ENTRY:%s %s%s",RVon,RVoff,ktarg,ksch+ksp); KOut(tempout); } if (ksp != is) @@ -543,9 +565,9 @@ { if (strlen(targ) != strlen(kanatab[ki])) continue; if (stringcomp(targ,kanatab[ki]) != 0) continue; - strcat(ktarg,kanatab[ki+1]); + strncat(ktarg,kanatab[ki+1],sizeof(ktarg)-1-strlen(ktarg)); ksp = ksp+rlen; - sprintf(tempout,"\r \r%sROMAJI ENTRY:%s %s%s",RVon,RVoff,ktarg,ksch+ksp); + snprintf(tempout,sizeof(tempout),"\r \r%sROMAJI ENTRY:%s %s%s",RVon,RVoff,ktarg,ksch+ksp); KOut(tempout); return (TRUE); } @@ -1066,7 +1088,7 @@ { int xjresp,roff,rlen; - unsigned char repstr[512]; + unsigned char repstr[MAX_ENTRY_SIZE]; long respos; int hit,schix; unsigned char khi,klo,cc,ops[4]; @@ -1255,7 +1277,7 @@ unsigned char vlast[11],temp[11],ops[80]; int vi,vok,prevch,KDNSflag,KDskip,KTest; int xjresp,roff,rlen; - unsigned char repstr[512]; + unsigned char repstr[MAX_ENTRY_SIZE]; unsigned long respos; vlast[0] = 0; @@ -1812,7 +1834,7 @@ KFlushRes = KFlush("Continue displaying radicals? (y/n)"); if (!KFlushRes) return; rstr[2] = 0; - sprintf(tempout,"%s Stroke Radicals ",rstr); + snprintf(tempout,sizeof(tempout),"%s Stroke Radicals ",rstr); strcpy(KLine,tempout); KFlushRes = KFlush("Continue displaying radicals? (y/n)"); if (!KFlushRes) return; @@ -1826,7 +1848,7 @@ KOutc(rstr[1]); KOutc(0xa1); KOutc(0xa1); - sprintf(tempout,"%s ",rstr+3); + snprintf(tempout,sizeof(tempout),"%s ",rstr+3); strcat(KLine,tempout); } KFlush(""); @@ -1919,7 +1941,7 @@ Dmode =1; fbuff[0] = 0; fbuff[1] = 0; if (hojof) fbuff[0] = 0x8f; - strcat(fbuff,instr); + strlcat(fbuff,instr,sizeof(fbuff)); fseek(stdin,0L,SEEK_END); /*kill any leftovers*/ KLookup(); instr[0] = 0; @@ -1953,7 +1975,7 @@ if(bit8) i--; if( i > 0) instr[--i] = 0; i--; - strcpy(fbuff,instr); + strncpy(fbuff,instr,sizeof(fbuff)); if (!NoSJIS) FixSJIS(fbuff); printf("\r \r"); printf("%s%s%s ",RVon,prompt,RVoff); @@ -1970,7 +1992,7 @@ } else { - strcpy(fbuff,instr); + strncpy(fbuff,instr,sizeof(fbuff)); if ((strlen(fbuff) % 2) > 0) fbuff[strlen(fbuff)-1] = 0; printf("\r \r"); printf("%s%s%s ",RVon,prompt,RVoff); @@ -2573,10 +2595,7 @@ /* M A I N */ -main(argc,argv) -int argc; -unsigned char **argv; - +main(int argc,char **argv) { int i,j,ip,cmdmode,bit8,escf; unsigned char *dicenv,strtmp[50]; @@ -2636,6 +2655,7 @@ else { i++; + if (i >= argc) continue; strcpy(xap,argv[i]); strcpy (strtmp,xap); } @@ -2651,6 +2671,7 @@ else { i++; + if (i >= argc) continue; strcpy(xap,argv[i]); strcpy (strtmp,xap); } @@ -2681,7 +2702,8 @@ else { i++; - strcpy(xap,argv[i]); + if (i >= argc) continue; + strncpy(xap,argv[i],sizeof(xap)); strcpy(host,xap); } printf("Command-line request to use server: %s\n",host); @@ -2696,6 +2718,7 @@ else { i++; + if (i >= argc) continue; strcpy(xap,argv[i]); portno = atoi(xap); } @@ -2713,6 +2736,7 @@ else { i++; + if (i >= argc) continue; strcpy(xap,argv[i]); strcpy (strtmp,xap); } @@ -2737,6 +2761,7 @@ else { i++; + if (i >= argc) continue; strcpy(xap,argv[i]); strcpy (strtmp,xap); } @@ -2756,6 +2781,7 @@ else { i++; + if (i >= argc) continue; strcpy(xap,argv[i]); strcpy (strtmp,xap); } @@ -2899,7 +2925,7 @@ if(bit8) i--; if( i > 0) instr[--i] = 0; i--; - strcpy(fbuff,instr); + strncpy(fbuff,instr,sizeof(fbuff)); if (!NoSJIS) FixSJIS(fbuff); printf("\r \r"); printf("%s",kbprompt); @@ -2932,7 +2958,7 @@ } else { - strcpy(fbuff,instr); + strncpy(fbuff,instr,sizeof(fbuff)); if ((strlen(fbuff) % 2) > 0) fbuff[strlen(fbuff)-1] = 0; printf("\r \r"); printf("%s",kbprompt); @@ -3093,7 +3119,7 @@ GetKBStr("INDEX CODE:"); fflush(stdin); Dmode =1; - strcat(fbuff," "); + strlcat(fbuff," ",sizeof(fbuff)); /* For bushu or classical radical, ask for stroke count */ if (((fbuff[0] | 0x20) == 'b')||((fbuff[0] | 0x20) == 'c')) { @@ -3104,7 +3130,7 @@ if((fbuff[1] != radkanj[i][0]) || (fbuff[2] != radkanj[i][1])) continue; sprintf(strtmp,"%d",radnos[i]); strcpy(fbuff+1,strtmp); - strcat(fbuff," "); + strlcat(fbuff," ",sizeof(fbuff)); printf("Bushu: %s\n",strtmp); break; } @@ -3205,7 +3231,7 @@ if(strlen(instr) < 2) continue; GetEUC(fbuff); if (escf) KOut(fbuff); - sprintf(tempout,"\nSearching for: %s%s%s\n",RVon,fbuff,RVoff); + snprintf(tempout,sizeof(tempout),"\nSearching for: %s%s%s\n",RVon,fbuff,RVoff); KOut(tempout); Dmode = 0; if (prieng && (fbuff[0] < 128)) /* if priority English key only */ @@ -3218,3 +3244,41 @@ Lookup(); } } + +/* + * Appends src to string dst of size siz (unlike strncat, siz is the + * full size of dst, not space left). At most siz-1 characters + * will be copied. Always NUL terminates (unless siz <= strlen(dst)). + * Returns strlen(src) + MIN(siz, strlen(initial dst)). + * If retval >= siz, truncation occurred. + */ +size_t +strlcat(dst, src, siz) + char *dst; + const char *src; + size_t siz; +{ + register char *d = dst; + register const char *s = src; + register size_t n = siz; + size_t dlen; + + /* Find the end of dst and adjust bytes left but don't go past end */ + while (n-- != 0 && *d != '\0') + d++; + dlen = d - dst; + n = siz - dlen; + + if (n == 0) + return(dlen + strlen(s)); + while (*s != '\0') { + if (n != 1) { + *d++ = *s; + n--; + } + s++; + } + *d = '\0'; + + return(dlen + (s - src)); /* count does not include NUL */ +} --- xjdic-24.orig/xjdic.1 +++ xjdic-24/xjdic.1 @@ -434,6 +434,12 @@ set the initial default input mode to hiragana .At +.B exactmatch +[SA,CL] +.Ap +toggles the exact match option +.At + .B dicdir path_name [SA,SV,CL] .Ap --- xjdic-24.orig/xjdic.h +++ xjdic-24/xjdic.h @@ -2,8 +2,8 @@ #define MAXCOLS 80 /* default cols per display */ #define NRKANA 250*2 /* size of the romaji to kana tables*/ #define NOFILT 10 /* maximum number of general filters */ -#define VMAX 350 /* maximum entries in the verb table */ -#define DEFAULT_DICDIR "" /* could be: "/usr/local/lib/xjdic" */ +#define VMAX 600 /* maximum entries in the verb table */ +#define DEFAULT_DICDIR "/var/lib/xjdic" /* could be: "/usr/local/lib/xjdic" */ #define NOHITS 1000 /* size of hittab */ #define SPTAG '@' /* character that flags priority entries */ #define KFBUFFSIZE 2000 /* size of the KFlush buffer */ @@ -19,6 +19,9 @@ lookup (default 20) */ #define MAXITER 40 /*maximum binary search iterations*/ +#define MAX_ENTRY_SIZE 4096 /* maximum size of an edict entry */ + /* (this only applies to the stand-alone client) */ + /* The following is for Solarises */ #ifndef SEEK_END --- xjdic-24.orig/xjdrad.c +++ xjdic-24/xjdrad.c @@ -149,15 +149,17 @@ /*=====xjdicrc - access and analyze "xjdicrc" file (if any)==============*/ void xjdicrc() { - unsigned char xjdicdir[128],rcstr[80],*rcwd; + unsigned char xjdicdir[256],rcstr[80],*rcwd; int ft,fn; FILE *fm,*fopen(); xjdicdir[0] = '\0'; if (strlen(ENVname) > 2) { - strcpy(xjdicdir,ENVname); - strcat(xjdicdir,"/"); + if (getenv("HOME") != NULL) { + strcpy(xjdicdir,ENVname); + strcat(xjdicdir,"/"); + } } else { @@ -172,7 +174,7 @@ strcpy(xjdicdir,".xjdicrc"); fm = fopen(xjdicdir,"r"); } - if (fm == NULL) + if (fm == NULL && getenv("HOME") != NULL) { strcpy(xjdicdir,getenv("HOME")); strcat(xjdicdir,"/"); --- xjdic-24.orig/xjdsa.c +++ xjdic-24/xjdsa.c @@ -186,7 +186,7 @@ *dic_loc = schix; for (i = 0; dbchar(schix+i) != 0x0a; i++) { - if (i == 512) + if (i == MAX_ENTRY_SIZE) { printf ("Reply overrun\n"); exit(1); --- xjdic-24.orig/xjdserver.c +++ xjdic-24/xjdserver.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -28,6 +29,7 @@ #include #include #include +#include #include "xjdic.h" #define SVERBOSE 0 @@ -56,8 +58,6 @@ int thisdic = 0; int DicNum; -extern int errno; - extern unsigned char Dnamet[10][100],XJDXnamet[10][100]; extern unsigned char *dicbufft[10]; extern unsigned long diclent[10], indlent[10],indptrt[10]; @@ -144,7 +144,7 @@ main(argc,argv) int argc; -unsigned char **argv; +char **argv; { int iterlimit,i; @@ -463,7 +463,7 @@ { pdu_out.xjdrsp_resindex = htonl(schix); } - for (i = 0; dbchar(schix+i) != 0x0a; i++) + for (i = 0; i < 510 && dbchar(schix+i) != 0x0a; i++) { pdu_out.xjdrsp_resstr[i] = dbchar(schix+i); } --- xjdic-24.orig/xjdxgen.c +++ xjdic-24/xjdxgen.c @@ -23,9 +23,10 @@ #include #include -/*#include */ +#include #include #include +#include #include "xjdic.h" #define TRUE 1 @@ -74,9 +75,7 @@ } /*====function to Load Dictionary and load/create index table=======*/ -main(argc,argv) -int argc; -unsigned char **argv; +main(int argc, char **argv) { FILE *fp,*fopen(); unsigned long possav,schi,diclen,indlen; @@ -113,7 +112,7 @@ strcpy(JDXname,*ap); strcat(JDXname,".xjdx"); printf("Commandline request to use files %s and %s \n",Dname,JDXname); - ap++; + //ap++; fix for Mayhem Debian #716516 arg_c--; } xjdicrc();