summaryrefslogtreecommitdiff
blob: afbac64bb1d8b147c29c64c31dc4eb32df22ed61 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
--- skktools-1.2+0.20061004.orig/skkdic-expr.c
+++ skktools-1.2+0.20061004/skkdic-expr.c
@@ -92,6 +92,7 @@
 char file_name[256];
 char okuri_tail_name[256];
 char okuri_head_name[256];
+char tmpsubdir[256];
 
 /* ����ѥǡ����١��� */
 DBM *db;
@@ -127,28 +128,28 @@
     char dir_name[256];
 
     db_remove_file(file_name);
-    sprintf(pag_name, "%s.pag", file_name);
+    snprintf(pag_name, sizeof(pag_name), "%s.pag", file_name);
     db_remove_file(pag_name);
-    sprintf(dir_name, "%s.dir", file_name);
+    snprintf(dir_name, sizeof(dir_name), "%s.dir", file_name);
     db_remove_file(dir_name);
-    sprintf(dir_name, "%s.db", file_name);
+    snprintf(dir_name, sizeof(dir_name), "%s.db", file_name);
     db_remove_file(dir_name);
 
     if (okurigana_flag) {
 	db_remove_file(okuri_head_name);
-	sprintf(pag_name, "%s.pag", okuri_head_name);
+	snprintf(pag_name, sizeof(pag_name), "%s.pag", okuri_head_name);
 	db_remove_file(pag_name);
-	sprintf(dir_name, "%s.dir", okuri_head_name);
+	snprintf(dir_name, sizeof(dir_name), "%s.dir", okuri_head_name);
 	db_remove_file(dir_name);
-	sprintf(dir_name, "%s.db", okuri_head_name);
+	snprintf(dir_name, sizeof(dir_name), "%s.db", okuri_head_name);
 	db_remove_file(dir_name);
 
 	db_remove_file(okuri_tail_name);
-	sprintf(pag_name, "%s.pag", okuri_tail_name);
+	snprintf(pag_name, sizeof(pag_name), "%s.pag", okuri_tail_name);
 	db_remove_file(pag_name);
-	sprintf(dir_name, "%s.dir", okuri_tail_name);
+	snprintf(dir_name, sizeof(dir_name), "%s.dir", okuri_tail_name);
 	db_remove_file(dir_name);
-	sprintf(dir_name, "%s.db", okuri_tail_name);
+	snprintf(dir_name, sizeof(dir_name), "%s.db", okuri_tail_name);
 	db_remove_file(dir_name);
     }
 }
@@ -235,6 +236,7 @@
      int signo;
 {
     db_remove_files();
+    rmdir(tmpsubdir);
     signal(signo, SIG_DFL);
     kill(getpid(), signo);
 }
@@ -816,10 +818,16 @@
 	exit(1);
     }
 
-    sprintf(file_name, "%s/skkdic%d", tmpdir, getpid());
+    snprintf(tmpsubdir, sizeof(tmpsubdir), "%s/skkdic%d", tmpdir, getpid());
+    if (mkdir(tmpsubdir, 0700)) {
+	perror(tmpsubdir);
+	exit(1);
+    }
+    tmpdir = tmpsubdir;
+    snprintf(file_name, sizeof(file_name), "%s/skkdic%d", tmpdir, getpid());
     if (okurigana_flag) {
-	sprintf(okuri_head_name, "%s/skkhead%d", tmpdir, getpid());
-	sprintf(okuri_tail_name, "%s/skktail%d", tmpdir, getpid());
+	snprintf(okuri_head_name, sizeof(okuri_head_name), "%s/skkhead%d", tmpdir, getpid());
+	snprintf(okuri_tail_name, sizeof(okuri_tail_name), "%s/skktail%d", tmpdir, getpid());
     }
     set_signal_handler();
     db_make_files();
@@ -845,6 +853,7 @@
     }
     type_out(output);
     db_remove_files();
+    rmdir(tmpsubdir);
     return 0;
 }