diff options
author | stephen <stephen@FreeBSD.org> | 2011-07-12 11:47:34 +0800 |
---|---|---|
committer | stephen <stephen@FreeBSD.org> | 2011-07-12 11:47:34 +0800 |
commit | ecf92f96f1be67e761228cd54a85e931c4bcbbf7 (patch) | |
tree | 2689a1226c0e34700081247f81b09609cf6071f7 /japanese | |
parent | 085cb28f20a9c1d2d81ddaf070e4851a8fffafa2 (diff) | |
download | freebsd-ports-gnome-ecf92f96f1be67e761228cd54a85e931c4bcbbf7.tar.gz freebsd-ports-gnome-ecf92f96f1be67e761228cd54a85e931c4bcbbf7.tar.zst freebsd-ports-gnome-ecf92f96f1be67e761228cd54a85e931c4bcbbf7.zip |
- Fix buffer overflow and mouse bugs.
- Bump portrevision.
PR: ports/127321
Submitted by: Arai Toshihiko <double_star@scorpio.plala.or.jp>
Approved by: gabor (mentor)
Diffstat (limited to 'japanese')
23 files changed, 869 insertions, 1 deletions
diff --git a/japanese/kon2-16dot/Makefile b/japanese/kon2-16dot/Makefile index 3e2d1ca0e4b3..92155c598357 100644 --- a/japanese/kon2-16dot/Makefile +++ b/japanese/kon2-16dot/Makefile @@ -7,7 +7,7 @@ PORTNAME= kon2 PORTVERSION= 0.3 -PORTREVISION= 3 +PORTREVISION= 4 # '+=' is for slave ports CATEGORIES+= japanese MASTER_SITES= ${MASTER_SITE_PORTS_JP} diff --git a/japanese/kon2-16dot/files/patch-font_fld.c b/japanese/kon2-16dot/files/patch-font_fld.c new file mode 100644 index 000000000000..3052e294ef8f --- /dev/null +++ b/japanese/kon2-16dot/files/patch-font_fld.c @@ -0,0 +1,74 @@ + --- font/fld.c 30 Sep 2008 08:02:59 -0000 1.1.1.1 + +++ font/fld.c 23 Oct 2008 09:24:33 -0000 + @@ -52,36 +52,13 @@ + {NULL, NULL} + }; + + -void UnloadShmem(char fnum) + -{ + - key_t shmkey; + - int shmid; + - struct shmid_ds shmseg; + - + -#if defined(linux) + - shmkey = ftok(CONFIG_NAME, fnum); + -#elif defined(__FreeBSD__) + - shmkey = 5000 + (fnum & 0x7F); + -#endif + - if ((shmid = shmget(shmkey, sizeof(struct fontInfo), 0444)) < 0) + - return; + - shmctl(shmid, IPC_STAT, &shmseg); + - if (shmseg.shm_nattch < 1) { + - shmctl(shmid, IPC_RMID, 0); + - } + -} + - + int CheckLoadedFont(char fnum) + { + key_t shmkey; + extern int forceLoad; + + if (forceLoad) return(EOF); + -#if defined(linux) + - shmkey = ftok(SHMEM_NAME, fnum); + -#elif defined(__FreeBSD__) + - shmkey = 5000 + (fnum & 0x7F); + -#endif + + shmkey = ftok(CONFIG_NAME, fnum); + if (shmget(shmkey, 1, 0444) == EOF) return(EOF); + return(0); + } + @@ -93,11 +70,7 @@ + int shmid; + u_char *shmbuff; + + -#if defined(linux) + - shmkey = ftok(SHMEM_NAME, fi->type); + -#elif defined(__FreeBSD__) + - shmkey = 5000 + (fi->type & 0x0000007F); + -#endif + + shmkey = ftok(CONFIG_NAME, fi->type); + shmid = shmget(shmkey, fi->size+sizeof(struct fontInfo), + IPC_CREAT|0666); + shmbuff = shmat(shmid, 0, 0); + @@ -134,11 +107,7 @@ + int shmid; + struct fontInfo *fi; + + -#if defined(linux) + shmkey = ftok(CONFIG_NAME, fnum); + -#elif defined(__FreeBSD__) + - shmkey = 5000 + (fnum & 0x7F); + -#endif + if ((shmid = shmget(shmkey, sizeof(struct fontInfo), 0444)) < 0) + return(0); + fi = (struct fontInfo*)shmat(shmid, 0, SHM_RDONLY); + @@ -194,7 +163,7 @@ + (n & CHR_DBC) ? + fDRegs[n&~CHR_DFLD].registry: + fSRegs[n&~CHR_SFLD].registry); + - UnloadShmem(n | CHR_SFLD); + + DownShmem(n | CHR_SFLD); + break; + } + st = ST_ARG; diff --git a/japanese/kon2-16dot/files/patch-font_fontx2.c b/japanese/kon2-16dot/files/patch-font_fontx2.c new file mode 100644 index 000000000000..0acd90f49c0c --- /dev/null +++ b/japanese/kon2-16dot/files/patch-font_fontx2.c @@ -0,0 +1,19 @@ + --- font/fontx2.c 30 Sep 2008 08:02:59 -0000 1.1.1.1 + +++ font/fontx2.c 23 Oct 2008 09:24:33 -0000 + @@ -37,6 +37,7 @@ + #include <string.h> + #include <sys/socket.h> + + +#include <defs.h> + #include <interface.h> + #include <fnld.h> + + @@ -170,7 +171,7 @@ + font = FontLoadSFontx(fp, header); + else exit(0); + } + - free(header); + + SafeFree(header); + return(font); + } + diff --git a/japanese/kon2-16dot/files/patch-include_defs.h b/japanese/kon2-16dot/files/patch-include_defs.h new file mode 100644 index 000000000000..62e6fa1ecaec --- /dev/null +++ b/japanese/kon2-16dot/files/patch-include_defs.h @@ -0,0 +1,9 @@ + --- include/defs.h 30 Sep 2008 08:02:59 -0000 1.1.1.1 + +++ include/defs.h 23 Oct 2008 09:27:32 -0000 + @@ -37,4 +37,6 @@ + #define FAILURE (-1) + #define SUCCESS (0) + + +#define SafeFree(x) do { if ((x) != NULL) free(x), (x) = NULL; } while (0) + + + #endif diff --git a/japanese/kon2-16dot/files/patch-include_fnld.h b/japanese/kon2-16dot/files/patch-include_fnld.h new file mode 100644 index 000000000000..1ccf63250a95 --- /dev/null +++ b/japanese/kon2-16dot/files/patch-include_fnld.h @@ -0,0 +1,13 @@ + --- include/fnld.h 30 Sep 2008 08:02:59 -0000 1.1.1.1 + +++ include/fnld.h 23 Oct 2008 09:24:33 -0000 + @@ -51,6 +51,10 @@ + #define FR_ATTACH 1 + #define FR_PROXY 2 + + +#if defined(__FreeBSD__) + +#define ftok(p, n) (5000 + ((n) & 0x7F)) + +#endif + + + extern struct fontRegs fSRegs[], fDRegs[]; + extern struct fontRegs *sbFReg, *dbFReg; + diff --git a/japanese/kon2-16dot/files/patch-include_mem.h b/japanese/kon2-16dot/files/patch-include_mem.h new file mode 100644 index 000000000000..c94dba660faa --- /dev/null +++ b/japanese/kon2-16dot/files/patch-include_mem.h @@ -0,0 +1,9 @@ + --- include/mem.h 30 Sep 2008 08:09:55 -0000 1.1.1.2 + +++ include/mem.h 23 Oct 2008 09:24:33 -0000 + @@ -111,6 +111,5 @@ + extern void wmove(void *, void *, int); + extern void lmove(void *, void *, int); + #endif + -extern void SafeFree(void **); + + #endif diff --git a/japanese/kon2-16dot/files/patch-include_term.h b/japanese/kon2-16dot/files/patch-include_term.h new file mode 100644 index 000000000000..69875c0b24cf --- /dev/null +++ b/japanese/kon2-16dot/files/patch-include_term.h @@ -0,0 +1,9 @@ + --- include/term.h 30 Sep 2008 08:02:59 -0000 1.1.1.1 + +++ include/term.h 23 Oct 2008 09:24:33 -0000 + @@ -36,5 +36,6 @@ + extern void TermStart(void); /* start procesing */ + extern void TermRestart(int fd); /* restart kon (args are read from fd) */ + extern int masterPty; /* master pseudo-tty file descriptor */ + +extern int TermGetNumber(void); + + #endif diff --git a/japanese/kon2-16dot/files/patch-include_vt.h b/japanese/kon2-16dot/files/patch-include_vt.h new file mode 100644 index 000000000000..a8cf30edfbb3 --- /dev/null +++ b/japanese/kon2-16dot/files/patch-include_vt.h @@ -0,0 +1,18 @@ + --- include/vt.h 30 Sep 2008 08:09:55 -0000 1.1.1.2 + +++ include/vt.h 23 Oct 2008 09:24:33 -0000 + @@ -59,12 +59,10 @@ + ins, + active, + wrap, + -#if defined(__FreeBSD__) + - text_mode, + - cursor_key_mode; + -#else + text_mode; + -#endif + +#if defined(__FreeBSD__) + + bool cursor_key_mode; + +#endif /* __FreeBSD__ */ + }; + + extern struct _con_info con; diff --git a/japanese/kon2-16dot/files/patch-lib_coding.c b/japanese/kon2-16dot/files/patch-lib_coding.c new file mode 100644 index 000000000000..68f941e47480 --- /dev/null +++ b/japanese/kon2-16dot/files/patch-lib_coding.c @@ -0,0 +1,10 @@ + --- lib/coding.c 30 Sep 2008 08:02:59 -0000 1.1.1.1 + +++ lib/coding.c 23 Oct 2008 09:24:33 -0000 + @@ -28,6 +28,7 @@ + #include <config.h> + + #include <stdio.h> + +#include <string.h> + #include <errno.h> + + #include <interface.h> diff --git a/japanese/kon2-16dot/files/patch-lib_font.c b/japanese/kon2-16dot/files/patch-lib_font.c new file mode 100644 index 000000000000..1c99e014ed21 --- /dev/null +++ b/japanese/kon2-16dot/files/patch-lib_font.c @@ -0,0 +1,26 @@ + --- lib/font.c 30 Sep 2008 08:02:59 -0000 1.1.1.1 + +++ lib/font.c 23 Oct 2008 09:24:33 -0000 + @@ -44,11 +44,7 @@ + int shmid; + struct shmid_ds shmseg; + + -#if defined(linux) + shmkey = ftok(CONFIG_NAME, fnum); + -#elif defined(__FreeBSD__) + - shmkey = 5000 + (fnum & 0x7F); + -#endif + if ((shmid = shmget(shmkey, sizeof(struct fontInfo), 0444)) < 0) + return; + shmctl(shmid, IPC_STAT, &shmseg); + @@ -63,11 +59,7 @@ + key_t shmkey; + int shmid; + + -#if defined(linux) + shmkey = ftok(CONFIG_NAME, fnum); + -#elif defined(__FreeBSD__) + - shmkey = 5000 + (fnum & 0x7F); + -#endif + if ((shmid = shmget(shmkey, sizeof(struct fontInfo), 0444)) < 0) return(0); + return((u_char*)shmat(shmid, 0, SHM_RDONLY)); + } diff --git a/japanese/kon2-16dot/files/patch-lib_getcap.c b/japanese/kon2-16dot/files/patch-lib_getcap.c new file mode 100644 index 000000000000..c6e8cdce4934 --- /dev/null +++ b/japanese/kon2-16dot/files/patch-lib_getcap.c @@ -0,0 +1,77 @@ + --- lib/getcap.c 30 Sep 2008 08:02:59 -0000 1.1.1.1 + +++ lib/getcap.c 23 Oct 2008 09:24:33 -0000 + @@ -73,8 +73,10 @@ + fprintf(stderr, "cap %s redefined (default %s)\r\n", name, + def_value ? def_value : "None"); + #endif + + SafeFree(cp->name); + cp->name = strdup(name); + cp->func = func; + + SafeFree(cp->def_value); + if (def_value) + cp->def_value = strdup(def_value); + return; + @@ -86,8 +88,10 @@ + fprintf(stderr, "cap %s defined (default %s)\r\n", name, + def_value ? def_value : "None"); + #endif + + SafeFree(cp->name); + cp->name = strdup(name); + cp->func = func; + + SafeFree(cp->def_value); + if (def_value) + cp->def_value = strdup(def_value); + return; + @@ -110,12 +114,9 @@ + fprintf(stderr, "cap %s deleted\r\n", cp->name); + #endif + cp->initialized = 0; + - if (cp->name) + - free(cp->name); + - if (cp->arg) + - free(cp->arg); + - if (cp->def_value) + - free(cp->def_value); + + SafeFree(cp->name); + + SafeFree(cp->arg); + + SafeFree(cp->def_value); + cp->name = cp->arg = cp->def_value = NULL; + } + } + @@ -149,10 +150,13 @@ + if ((c = FindCap(p)) != NULL) { + /* Found matching capability. Get body from file. */ + char *l = buf; + + int bnum = 0; + while (fgets(line, MAX_COLS, capFp) != NULL + && line[0] == '\t') { + char *l2 = line; + while (*l2 != '\n' && *l2 != '#') { + + if (++bnum > BUF_SIZE - 2) + + fatal("buffer overflow at configuration file\n"); + *l++ = *l2++; + } + *l++ = '\n'; + @@ -223,6 +227,7 @@ + /* Protected capability. */ + return FAILURE; + } + + SafeFree(cp->arg); + cp->arg = strdup(value); + #ifdef DEBUG + fprintf(stderr, "Setting arg for %s to %s\r\n", capName, value); + @@ -234,8 +239,12 @@ + + bool BoolConf(const char *confstr) + { + - char name[MAX_COLS]; + - sscanf(confstr, "%s", name); + + char *name, *last, *sep = " \t\r\n"; + + + + name = strtok_r((char *)confstr, sep, &last); + + if (name == NULL) + + return FALSE; + + + if (strcasecmp(name, "On") == 0 || + strcasecmp(name, "True") == 0) { + return TRUE; diff --git a/japanese/kon2-16dot/files/patch-lib_mem.c b/japanese/kon2-16dot/files/patch-lib_mem.c new file mode 100644 index 000000000000..8356f0f0bb9d --- /dev/null +++ b/japanese/kon2-16dot/files/patch-lib_mem.c @@ -0,0 +1,13 @@ + --- lib/mem.c 30 Sep 2008 08:09:56 -0000 1.1.1.2 + +++ lib/mem.c 23 Oct 2008 09:24:33 -0000 + @@ -79,10 +79,3 @@ + } + #endif + + -void SafeFree(void **p) + -{ + - if (*p) { + - free(*p); + - *p = NULL; + - } + -} diff --git a/japanese/kon2-16dot/files/patch-src_child.c b/japanese/kon2-16dot/files/patch-src_child.c new file mode 100644 index 000000000000..5140a9ef80f5 --- /dev/null +++ b/japanese/kon2-16dot/files/patch-src_child.c @@ -0,0 +1,92 @@ + --- src/child.c 30 Sep 2008 08:09:56 -0000 1.1.1.2 + +++ src/child.c 23 Oct 2008 09:24:33 -0000 + @@ -40,16 +40,18 @@ + #include <version.h> + #include <vc.h> + + -static char *startupStr, *execProg; + +static char *startupStr = NULL, *execProg = NULL; + + int ConfigExecProg(const char *string) + { + + SafeFree(execProg); + execProg = strdup(string); + return SUCCESS; + } + + static int ConfigStartup(const char *string) + { + + SafeFree(startupStr); + startupStr = strdup(string); + return SUCCESS; + } + @@ -81,7 +83,8 @@ + + void ChildCleanup(void) + { + - free(startupStr); + + SafeFree(startupStr); + + SafeFree(execProg); + } + + void ChildStart(FILE *errfp) + @@ -105,46 +108,44 @@ + win.ws_col = dInfo.txmax + 1; + win.ws_xpixel = win.ws_ypixel = 0; + ioctl(STDIN_FILENO, TIOCSWINSZ, &win); + - sprintf(buff,"TERM=vt100"); + -#endif + + strcpy(buff, "TERM=vt100-color"); + +#endif /* __FreeBSD__ */ + + tcap = strdup(buff); + putenv(tcap); + + - if (startupMessage) + + if (startupMessage) { + printf("\rKON2 Kanji On Console " VERSION + - " using VT number %c\r\n" + + " using VT number %d\n" + "%*s\r\n" + -#if defined(__FreeBSD__) + - "%*s\r\n", *(ttyname(fileno(errfp))+9), + -#else /* linux */ + - "%*s\r\n", *(ttyname(fileno(errfp))+8), + -#endif + + "%*s\r\n", + + TermGetNumber(), + dInfo.txmax, + "Copyright (C) " + "1993-1996 Takashi MANABE", + dInfo.txmax, + "1993, 1994 MAEDA Atusi "); + #if defined(__FreeBSD__) + - printf("\rKON for FreeBSD-2.x ver0.01 Takashi OGURA\r\n"); + + printf("\rKON for FreeBSD-2.x ver0.01 Takashi OGURA\r\n"); + #endif + - + + } + + /* + - printf("KON using VT number %c.\n\n", + - *(ttyname(fileno(errfp))+8)); + + printf("KON using VT number %d.\n\n", TermGetNumber()); + */ + fflush(stdout); + + if (execProg) + execlp(execProg, execProg, 0); + else { + + char *ptr; + if ((execProg = getenv("SHELL")) == NULL) + execProg = "/bin/sh"; + if ((tail = rindex(execProg, '/')) == NULL) + tail = " sh"; + - sprintf(buff, "-%s", tail + 1); + - execl(execProg, buff, 0); + + ptr = strdup(tail); + + *ptr = '-'; + + execl(execProg, ptr, 0); + } + fprintf(errfp, "KON> couldn't exec shell\r\n"); + fprintf(errfp, "%s: %s\r\n", execProg, strerror(errno)); diff --git a/japanese/kon2-16dot/files/patch-src_display_j31sx.c b/japanese/kon2-16dot/files/patch-src_display_j31sx.c new file mode 100644 index 000000000000..958329a02f3b --- /dev/null +++ b/japanese/kon2-16dot/files/patch-src_display_j31sx.c @@ -0,0 +1,19 @@ + --- src/display/j31sx.c 30 Sep 2008 08:02:59 -0000 1.1.1.1 + +++ src/display/j31sx.c 23 Oct 2008 09:24:33 -0000 + @@ -49,7 +49,6 @@ + #include <sys/mman.h> + #include <linux/mm.h> + #include <sys/kd.h> + -#undef free + #include <stdlib.h> + + #include <mem.h> + @@ -365,8 +364,6 @@ + ioperm(CGA_COLOR, 1, 0); + + munmap(gram, GRAPH_SIZE); + - + - SafeFree((void **)&gram); + } + + static struct videoInfo J31SXInfo = diff --git a/japanese/kon2-16dot/files/patch-src_display_s3.c b/japanese/kon2-16dot/files/patch-src_display_s3.c new file mode 100644 index 000000000000..a8efe8d4b5fe --- /dev/null +++ b/japanese/kon2-16dot/files/patch-src_display_s3.c @@ -0,0 +1,10 @@ + --- src/display/s3.c 30 Sep 2008 08:02:59 -0000 1.1.1.1 + +++ src/display/s3.c 23 Oct 2008 09:24:33 -0000 + @@ -43,7 +43,6 @@ + #include <sys/mman.h> + #include <linux/mm.h> + #include <sys/kd.h> + -#undef free + #include <stdlib.h> + + #include <mem.h> diff --git a/japanese/kon2-16dot/files/patch-src_display_svga.c b/japanese/kon2-16dot/files/patch-src_display_svga.c new file mode 100644 index 000000000000..d8690a035d99 --- /dev/null +++ b/japanese/kon2-16dot/files/patch-src_display_svga.c @@ -0,0 +1,10 @@ + --- src/display/svga.c 30 Sep 2008 08:02:59 -0000 1.1.1.1 + +++ src/display/svga.c 23 Oct 2008 09:24:33 -0000 + @@ -45,7 +45,6 @@ + /* #include <linux/mm.h> */ + #include <sys/kd.h> + #endif + -#undef free + #include <stdlib.h> + + #include <mem.h> diff --git a/japanese/kon2-16dot/files/patch-src_display_vga.c b/japanese/kon2-16dot/files/patch-src_display_vga.c new file mode 100644 index 000000000000..cc2ffe5b6fe2 --- /dev/null +++ b/japanese/kon2-16dot/files/patch-src_display_vga.c @@ -0,0 +1,25 @@ + --- src/display/vga.c 30 Sep 2008 08:09:56 -0000 1.1.1.2 + +++ src/display/vga.c 23 Oct 2008 09:24:33 -0000 + @@ -56,7 +56,6 @@ + #endif + vm_size_t page_size; + #endif + -#undef free + #include <stdlib.h> + + #include <mem.h> + @@ -691,10 +690,9 @@ + + munmap(gramMem, dInfo.gsize); + + - SafeFree((void **)&gramMem); + - SafeFree((void **)&fontBuff1); + + SafeFree(fontBuff1); + if (savePlane3) + - SafeFree((void **)&fontBuff2); + + SafeFree(fontBuff2); + } + + /* Configure */ + + diff --git a/japanese/kon2-16dot/files/patch-src_errors.c b/japanese/kon2-16dot/files/patch-src_errors.c new file mode 100644 index 000000000000..5c402634e313 --- /dev/null +++ b/japanese/kon2-16dot/files/patch-src_errors.c @@ -0,0 +1,11 @@ + --- src/errors.c 30 Sep 2008 08:02:59 -0000 1.1.1.1 + +++ src/errors.c 23 Oct 2008 09:24:33 -0000 + @@ -48,7 +48,7 @@ + vfprintf(stderr, format, args); + } else { + VtEmu(head, strlen(head)); + - vsprintf(buf, format, args); + + vsnprintf(buf, sizeof(buf), format, args); + VtEmu(buf, strlen(buf)); + } + } diff --git a/japanese/kon2-16dot/files/patch-src_main.c b/japanese/kon2-16dot/files/patch-src_main.c new file mode 100644 index 000000000000..bd2aca5e612d --- /dev/null +++ b/japanese/kon2-16dot/files/patch-src_main.c @@ -0,0 +1,56 @@ + --- src/main.c 30 Sep 2008 08:09:56 -0000 1.1.1.2 + +++ src/main.c 23 Oct 2008 09:24:33 -0000 + @@ -29,11 +29,45 @@ + #include <stdlib.h> + #include <unistd.h> + + +#if defined(__FreeBSD__) + +#include <err.h> + +#include <osreldate.h> + +#if __FreeBSD_version >= 410000 + +# include <sys/consio.h> + +# include <sys/kbio.h> + +#else + +# include <machine/console.h> + +#endif + +#endif /* __FreeBSD__ */ + + + #include <getcap.h> + + #include <version.h> + #include <term.h> + + +/* handler for atexit() */ + +static void + +reset_text_mode(void) + +{ + + int mode; + + + +#if defined(__FreeBSD__) + + if (ioctl(0, KDGETMODE, &mode) == -1) + + warn("ioctl(0, KDGETMODE)"); + + else if (mode != KD_TEXT) { + + ioctl(0, KDSETMODE, KD_TEXT); + + } + + + +#elif defined(__NetBSD__) + + if (ioctl(0, WSDISPLAYIO_GMODE, &mode) == -1) + + warn("ioctl(0, WSDISPLAYIO_GMODE)"); + + else if (mode != WSDISPLAYIO_MODE_EMUL) { + + mode = WSDISPLAYIO_MODE_EMUL; + + ioctl(0, WSDISPLAYIO_SMODE, &mode); + + } + +#endif /* __NetBSD__ */ + +} + + + int main(int argc, const char *argv[]) + { + char *p; + @@ -43,6 +77,7 @@ + fprintf(stderr, "can not get I/O permissions.\n"); + exit(EXIT_FAILURE); + } + + atexit(reset_text_mode); + ChangeNewConsole(); + TermInit(argc - 1, argv + 1); + if (ReadConfig(CONFIG_NAME) < 0) { diff --git a/japanese/kon2-16dot/files/patch-src_mouse.c b/japanese/kon2-16dot/files/patch-src_mouse.c new file mode 100644 index 000000000000..5b6607c63914 --- /dev/null +++ b/japanese/kon2-16dot/files/patch-src_mouse.c @@ -0,0 +1,73 @@ + --- src/mouse.c 30 Sep 2008 08:09:56 -0000 1.1.1.2 + +++ src/mouse.c 23 Oct 2008 09:24:33 -0000 + @@ -122,11 +122,11 @@ + } + }; + + -static int mouseBaud; + +static int mouseBaud = B1200; + + static int ConfigMouseBaud(const char *config) + { + - int baud; + + int baud = 0; + + sscanf(config, "%d", &baud); + + @@ -149,19 +149,23 @@ + return SUCCESS; + } + + -static char *mouseDev; + +static char *mouseDev = NULL; + + static int ConfigMouseDev(const char *config) + { + - char name[MAX_COLS]; + - sscanf(config, "%s", name); + + char *name, *last, *sep = " \t\r\n"; + + - if (mouseDev) free(mouseDev); + + name = strtok_r((char *)config, sep, &last); + + if (name == NULL) { + + warn("unknown mouse type ignored; assuming no mouse\r\n"); + + return SUCCESS; + + } + + SafeFree(mouseDev); + mouseDev = strdup(name); + return SUCCESS; + } + + -static int pasteButton; + +static int pasteButton = MOUSE_RGT; + + static int Config3Buttons(const char *config) + { + @@ -172,12 +176,15 @@ + static int ConfigMouse(const char *config) + { + struct mouseconf *p; + - char name[MAX_COLS]; + + char *name, *last, *sep = " \t\r\n"; + + mouseType = MOUSE_NONE; + mInfo.has_mouse = FALSE; + - strncpy(name, config, MAX_COLS - 1); + - name[MAX_COLS - 1] = '\0'; + + name = strtok_r((char *)config, sep, &last); + + if (name == NULL) { + + warn("unknown mouse type ignored; assuming no mouse\r\n"); + + return SUCCESS; + + } + for (p = mice; p->name != NULL; p++) { + if (strcasecmp(name, p->name) == 0) { + mouseType = p->type; + @@ -254,7 +261,7 @@ + if ((mfd = open(mouseDev, O_RDWR|O_NONBLOCK)) < 0) { + warn("couldn't open mouse device; mouse disabled\n"); + Perror(mouseDev); + - free(mouseDev); + + SafeFree(mouseDev); + mouseDev = NULL; + mInfo.has_mouse = FALSE; + return -1; diff --git a/japanese/kon2-16dot/files/patch-src_term.c b/japanese/kon2-16dot/files/patch-src_term.c new file mode 100644 index 000000000000..a5306cd0227c --- /dev/null +++ b/japanese/kon2-16dot/files/patch-src_term.c @@ -0,0 +1,185 @@ + --- src/term.c 30 Sep 2008 08:09:56 -0000 1.1.1.2 + +++ src/term.c 23 Oct 2008 09:24:33 -0000 + @@ -76,7 +76,7 @@ + + int masterPty; /* master pseudo-tty file descriptor */ + + -#define MAX_TTYNAME 10 + +#define MAX_TTYNAME 20 + + static int childPid, sockFd, slavePty; + static struct termio oldTio; + @@ -235,13 +235,16 @@ + } + ConsoleInit(video); + while (i < argc) { + - const char *arg; + + const char *arg = argv[i]; + + - if (argv[i][0] != '-') { + - warn("bad arg `%s'; assumed `-%s'\r\n", argv[i]); + - arg = (char *) argv[i]; + - } else + - arg = (char *) argv[i] + 1; + + if (*arg != '-') + + warn("bad arg `%s'; assumed `-%s'\n", arg, arg); + + else + + ++arg; + + if (!strcasecmp(arg, "help")) { + + message("Usage: kon2 [video] [-option value] ...\n"); + + exit(EXIT_FAILURE); + + } + i++; + if (i >= argc) { + error("no value for `%s'\r\n", arg); + @@ -258,6 +261,25 @@ + static int savedArgc; /* argc of startup time */ + static const char **savedArgv; /* argv of startup time */ + + +static int ttyNumber = 0; + + + +int + +set_vt_number(void) + +{ + +#if defined(__FreeBSD__) + + ttyNumber = strtol(ttyname(0) + 9, NULL, 16); + +#elif defined(linux) + + ttyNumber = atoi(ttyname(0) + 8); + +#endif /* linux */ + + return ttyNumber; + +} + + + +int + +TermGetNumber(void) + +{ + + return ttyNumber; + +} + + + /* Do initialization before reading config file */ + void TermInit(int argc, const char *argv[]) + { + @@ -266,6 +288,7 @@ + init.display = init.utmp = init.socket = init.termio = FALSE; + /* Initialize subsystems. */ + + + set_vt_number(); + CapInit(); + ChildInit(); + MouseInit(); + @@ -355,8 +378,8 @@ + mouseFd = MouseStart(); + } + + - chown("/dev/tty0", getuid(), getgid()); + #if defined(linux) + + chown("/dev/tty0", getuid(), getgid()); + sockFd = SocketInit(ttyname(0) + 8); + #elif defined(__FreeBSD__) + sockFd = SocketInit(ttyname(0) + 9); + @@ -381,6 +404,7 @@ + + /* Signal Setting */ + signal(SIGCHLD, ExitPty); + + signal(SIGPIPE, SIG_IGN); + signal(SIGHUP, ExitTerm); + signal(SIGTERM, ExitTerm); + signal(SIGSEGV, ExitTerm); + @@ -458,18 +482,13 @@ + PerrorExit("/dev/console"); + } + #elif defined(__FreeBSD__) + -#if __FreeBSD_version >= 501100 + - cfd = open("/dev/ttyv0", O_WRONLY); + - if (cfd < 0 && (cfd = open("/dev/ttyv0", O_RDONLY)) < 0) { + - PerrorExit("/dev/ttyv0"); + - } + -#else + - cfd = open("/dev/vga", O_WRONLY); + - if (cfd < 0 && (cfd = open("/dev/vga", O_RDONLY)) < 0) { + - PerrorExit("/dev/vga"); + + cfd = open("/dev/vga", O_RDONLY); + + if (cfd == -1) { + + cfd = open("/dev/console", O_RDONLY); + + if (cfd == -1) + + PerrorExit("/dev/console"); + } + -#endif + -#endif + +#endif /* __FreeBSD__ */ + ioctl(cfd, VT_ACTIVATE, orgVtNum); + close(cfd); + } + @@ -486,28 +505,36 @@ + cfd = open("/dev/console", O_WRONLY); + if (cfd < 0 && (cfd = open("/dev/console", O_RDONLY)) < 0) + fatal("can't open /dev/console"); + -#elif defined(__FreeBSD__) + -#if __FreeBSD_version >= 501100 + - cfd = open("/dev/ttyv0", O_WRONLY); + - if (cfd < 0 && (cfd = open("/dev/ttyv0", O_RDONLY)) < 0) + - fatal("can't open /dev/ttyv0"); + -#else + - cfd = open("/dev/vga", O_WRONLY); + - if (cfd < 0 && (cfd = open("/dev/vga", O_RDONLY)) < 0) + - fatal("can't open /dev/vga"); + -#endif + -#endif + + + ioctl(cfd, KDGETMODE, &mode); + if (mode == KD_TEXT) { + close(cfd); + return; + } + -#if defined(linux) + ioctl(cfd, VT_GETSTATE, &vts); + orgVtNum = vts.v_active; + -#endif + - ioctl(cfd, VT_OPENQRY, &vtNum); + - if (vtNum < 0) + + + +#elif defined(__FreeBSD__) + + /* check for syscons mode */ + + if (ioctl(0, KDGETMODE, &mode) == -1) + + fatal("KON is require the syscons(4)"); + + else if (mode != KD_TEXT) + + fatal("unknown terminal mode."); + + else if (strcmp(ttyname(0), "/dev/console") != 0) + + return; + + + + cfd = open("/dev/vga", O_RDONLY); + + if (cfd == -1) { + + cfd = open("/dev/console", O_RDONLY); + + if (cfd == -1) + + fatal("can't open /dev/console"); + + } + + if (ioctl(cfd, VT_GETINDEX, &orgVtNum) == -1) + + fatal("ioctl(VT_GETINDEX)"); + +#endif /* __FreeBSD__ */ + + + + errno = 0; + + if (ioctl(cfd, VT_OPENQRY, &vtNum) == -1 || vtNum < 0) + fatal("can't get free VC"); + parent = getpid(); + if ((child = fork()) == -1) + @@ -515,12 +542,13 @@ + if (child) { + signal(SIGHUP, ExitPty); + pause(); + + fatal("internal error."); + } + setsid(); + #if defined(linux) + sprintf(vtty, "/dev/tty%d", vtNum); + #elif defined(__FreeBSD__) + - sprintf(vtty, "/dev/ttyv%d", vtNum); + + sprintf(vtty, "/dev/ttyv%d", vtNum - 1); + #endif + if ((vfd = open(vtty, O_RDWR)) < 0) + fatal("can't open %s", vtty); + @@ -531,5 +559,6 @@ + dup2(vfd, 0); + dup2(vfd, 1); + dup2(vfd, 2); + + close(vfd); + kill(parent, SIGHUP); + } diff --git a/japanese/kon2-16dot/files/patch-src_vc.c b/japanese/kon2-16dot/files/patch-src_vc.c new file mode 100644 index 000000000000..c071a067a028 --- /dev/null +++ b/japanese/kon2-16dot/files/patch-src_vc.c @@ -0,0 +1,59 @@ + --- src/vc.c 30 Sep 2008 08:09:56 -0000 1.1.1.2 + +++ src/vc.c 23 Oct 2008 09:24:33 -0000 + @@ -792,22 +792,21 @@ + return SUCCESS; + } + + -static char *videoName; + +static char *videoName = NULL; + + static int ConfigDisplay(const char *config) + { + struct videoconf *v; + - char name[MAX_COLS]; + - + - sscanf(config, "%s", name); + + char *name, *last, *sep = " \t\r\n"; + + + + name = strtok_r((char *)config, sep, &last); + + if (name == NULL) { + + error("invalid entry for %s\r\n", videoName); + + return FAILURE; + + } + for (v = videos; v->name != NULL; v++) { + if (strcasecmp(name, v->name) == 0) { + - config = strchr(config, '\n'); + - if (config == NULL) { + - error("invalid entry for %s\r\n", videoName); + - return FAILURE; + - } + - if (v->set(&vInfo, config) == FAILURE) + + if (v->set(&vInfo, last) == FAILURE) + return FAILURE; + message("video type `%s' selected\r\n", name); + if (vInfo.has_hard_scroll) { + @@ -873,6 +872,7 @@ + + void ConsoleInit(const char *video) + { + + SafeFree(videoName); + videoName = strdup(video); + DefineCap(videoName, ConfigDisplay, NULL); + DefineCap("BeepCounter", ConfigBeep, "5"); + @@ -900,12 +900,12 @@ + { + scrollLine = textHead = 0; + vInfo.detatch(); + - SafeFree((void **)&textBuff); + - SafeFree((void **)&attrBuff); + - SafeFree((void **)&flagBuff); + + SafeFree(textBuff); + + SafeFree(attrBuff); + + SafeFree(flagBuff); + #ifdef linux + ioperm(COUNTER_ADDR, 1, FALSE); + #endif + + - SafeFree((void **)&videoName); + + SafeFree(videoName); + } diff --git a/japanese/kon2-16dot/files/patch-src_vt.c b/japanese/kon2-16dot/files/patch-src_vt.c new file mode 100644 index 000000000000..ce45879e48a2 --- /dev/null +++ b/japanese/kon2-16dot/files/patch-src_vt.c @@ -0,0 +1,51 @@ + --- src/vt.c 30 Sep 2008 08:09:56 -0000 1.1.1.2 + +++ src/vt.c 23 Oct 2008 09:24:33 -0000 + @@ -107,7 +107,7 @@ + con.bcol = saveAttr->bcol; + tmp = saveAttr; + saveAttr = tmp->prev; + - free(tmp); + + SafeFree(tmp); + } + } + + @@ -606,20 +606,23 @@ + + static int ConfigCoding(const char *confstr) + { + - char reg[3][MAX_COLS]; + + char *name, *last, *sep = " \t\r\n"; + int n, i; + + - *reg[0] = *reg[1] = *reg[2] = '\0'; + - sscanf(confstr, "%s %s %s", reg[0], reg[1], reg[2]); + - for (i = 0; i < 3 && *reg[i]; i ++) { + - n = (int)CodingByRegistry(reg[i]); + + name = strtok_r((char *)confstr, sep, &last); + + for (i = 0; i < 3; i++) { + + if (name == NULL) { + + error("invalid coding system\n"); + + return FAILURE; + + } + + n = (int)CodingByRegistry(name); + if (n < 0) { + - if (!strcasecmp(reg[i], "EUC")) + + if (!strcasecmp(name, "EUC")) + lInfo.sc = CODE_EUC; + - else if (!strcasecmp(reg[i], "SJIS")) + + else if (!strcasecmp(name, "SJIS")) + lInfo.sc = CODE_SJIS; + /* + - else if (!strcasecmp(reg[i], "BIG5")) + + else if (!strcasecmp(name, "BIG5")) + lInfo.sc = CODE_BIG5; + */ + else + @@ -633,6 +636,7 @@ + fprintf(fp,"[<%s> %d %d %d %d]\n", reg[i], n, lInfo.sb, lInfo.db, lInfo.sc); + fclose(fp);} + #endif + + name = strtok_r(NULL, sep, &last); + } + return SUCCESS; + } |