Changeset 18
- Timestamp:
- Jan 28, 2006, 9:07:52 PM (19 years ago)
- Location:
- trunk
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/COPYING
r1 r18 241 241 either version 2 of the License, or (at your option) any later version." 242 242 243 (x) Unit testing uses the 'cutest' framework by Asim Jalis, (files 244 CuTest.h, CuTest.c, make-tests.sh) which is licensed under the zlib license: 245 246 * Copyright (c) 2003 Asim Jalis 247 * 248 * This software is provided 'as-is', without any express or implied 249 * warranty. In no event will the authors be held liable for any damages 250 * arising from the use of this software. 251 * 252 * Permission is granted to anyone to use this software for any purpose, 253 * including commercial applications, and to alter it and redistribute it 254 * freely, subject to the following restrictions: 255 * 256 * 1. The origin of this software must not be misrepresented; you must not 257 * claim that you wrote the original software. If you use this software in 258 * a product, an acknowledgment in the product documentation would be 259 * appreciated but is not required. 260 * 261 * 2. Altered source versions must be plainly marked as such, and must not 262 * be misrepresented as being the original software. 263 * 264 * 3. This notice may not be removed or altered from any source 265 * distribution. 266 243 267 244 268 Other -
trunk/Makefile.in
r1 r18 57 57 XOR_CODE = @xor_code@ 58 58 SH_LKM = @sh_lkm@ 59 TIGER_SRC = @tiger_src@ 59 60 60 61 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 … … 63 64 64 65 CC = @CC@ 66 # DBGDEF = -pg -DSH_PROFILE=1 65 67 DBGDEF = @mydebugdef@ 66 68 DEFS = $(DBGDEF) @DEFS@ -I. -I$(top_srcdir)/include … … 98 100 lzoconf.h minilzo.h rijndael-alg-fst.h rijndael-api-fst.h \ 99 101 rijndael-boxes-fst.h sh_socket.h sh_ignore.h sh_prelude.h \ 100 sh_mounts.h sh_userfiles.h sh_static.h sh_prelink.h 102 sh_mounts.h sh_userfiles.h sh_static.h sh_prelink.h 101 103 102 104 … … 130 132 $(srcsrc)/sh_userfiles.c $(srcsrc)/sh_prelude.c \ 131 133 $(srcsrc)/sh_prelink.c $(srcsrc)/sh_static.c \ 132 $(srcsrc)/sh_prelude_old.c 133 134 OBJECTS = samhain.o sh_unix.o sh_utils.o sh_error.o sh_files.o \ 135 sh_getopt.o sh_readconf.o sh_tiger0.o sh_tiger1.o sh_tiger2.o \ 136 sh_tiger1_64.o sh_tiger2_64.o sh_hash.o sh_mail.o sh_mem.o \ 134 $(srcsrc)/sh_prelude_old.c 135 136 OBJECTS = sh_files.o sh_tiger0.o sh_tiger2.o sh_tiger2_64.o \ 137 samhain.o sh_unix.o sh_utils.o sh_error.o \ 138 sh_getopt.o sh_readconf.o \ 139 sh_hash.o sh_mail.o sh_mem.o \ 137 140 sh_entropy.o sh_forward.o sh_modules.o sh_utmp.o sh_kern.o \ 138 141 sh_suidchk.o sh_srp.o sh_fifo.o sh_tools.o sh_html.o sh_gpg.o \ … … 141 144 trustfile.o rijndael-alg-fst.o rijndael-api-fst.o slib.o \ 142 145 zAVLTree.o sh_socket.o sh_ignore.o sh_prelude.o \ 143 sh_mounts.o sh_userfiles.o sh_prelink.o sh_static.o sh_prelude_old.o 146 sh_mounts.o sh_userfiles.o sh_prelink.o sh_static.o \ 147 sh_prelude_old.o 144 148 145 149 KERN = kern_head.h kern_head.c … … 1057 1061 rm x_`echo $@ |sed 's%\.o$$%%'`.c 1058 1062 1063 sh_tiger_i.o: $(srcsrc)/$(TIGER_SRC) Makefile config_xor.h 1064 @echo "$(COMPILE) $(VFLAG) -o sh_tiger_i.o -c $(srcsrc)/$(TIGER_SRC)";\ 1065 $(COMPILE) $(VFLAG) -o sh_tiger_i.o -c $(srcsrc)/$(TIGER_SRC); 1066 1059 1067 samhain_setpwd: encode config_xor.h $(srcsrc)/samhain_setpwd.c 1060 1068 @echo '$(COMPILE) -o samhain_setpwd $(srcsrc)/samhain_setpwd.c'; \ … … 1075 1083 rm x_yulectl.c 1076 1084 1077 $(SAMHAIN): internal.h $(OBJECTS) 1085 $(SAMHAIN): internal.h $(OBJECTS) sh_tiger_i.o 1078 1086 @-rm -f $(SAMHAIN) 1079 @echo "$(LINK) $(OBJECTS) $(LIBS_TRY)"; \ 1080 $(LINK) $(OBJECTS) $(LIBS_TRY) 1081 1082 1087 @echo "$(LINK) sh_tiger_i.o $(OBJECTS) $(LIBS_TRY)"; \ 1088 $(LINK) sh_tiger_i.o $(OBJECTS) $(LIBS_TRY) 1089 1090 1091 CUTEST_SOURCES = $(srcsrc)/cutest_sh_tools.c \ 1092 $(srcsrc)/cutest_zAVLTree.c \ 1093 $(srcsrc)/cutest_sh_tiger0.c 1094 1095 CUTEST_OBJECTS = cutest_sh_tools.o cutest_zAVLTree.o cutest_sh_tiger0.o 1096 1097 $(CUTEST_OBJECTS): $(CUTEST_SOURCES) 1098 @echo "./encode $(XOR_CODE) $(srcsrc)/`echo $@ |sed 's%\.o$$%%'`.c --> x_`echo $@ |sed 's%\.o$$%%'`.c"; \ 1099 ./encode $(XOR_CODE) $(srcsrc)/`echo $@ |sed 's%\.o$$%%'`.c; \ 1100 echo "$(COMPILE) $(VFLAG) -o `echo $@ |sed 's%.*/%%'` -c x_`echo $@ |sed 's%\.o$$%%'`.c"; \ 1101 $(COMPILE) $(VFLAG) -o `echo $@ |sed 's%.*/%%'` -c x_`echo $@ |sed 's%\.o$$%%'`.c; \ 1102 rm x_`echo $@ |sed 's%\.o$$%%'`.c 1103 1104 cutest: internal.h $(OBJECTS) $(CUTEST_OBJECTS) sh_tiger_i.o $(srcsrc)/make-tests.sh 1105 cd $(srcsrc)/ && ./make-tests.sh >CuTestMain.c 1106 @$(COMPILE) -o CuTestMain.o -c $(srcsrc)/CuTestMain.c; \ 1107 $(COMPILE) -o CuTest.o -c $(srcsrc)/CuTest.c; \ 1108 rm -f samhain.o; \ 1109 ./encode $(XOR_CODE) $(srcsrc)/samhain.c; \ 1110 $(COMPILE) $(VFLAG) -DSH_CUTEST=1 -o samhain.o -c x_samhain.c; \ 1111 rm x_samhain.c; \ 1112 $(LINK) sh_tiger_i.o $(CUTEST_OBJECTS) CuTestMain.o CuTest.o $(OBJECTS) $(LIBS_TRY); \ 1113 ./cutest 1083 1114 1084 1115 samhain_hide.o: $(srcsrc)/samhain_hide.c samhain_erase.o … … 1596 1627 sh_static.o: $(srcsrc)/sh_static.c Makefile config_xor.h 1597 1628 sh_prelude_old.o: $(srcsrc)/sh_prelude_old.c Makefile config_xor.h $(srcinc)/slib.h $(srcinc)/sh_mem.h $(srcinc)/sh_cat.h $(srcinc)/sh_error_min.h $(srcinc)/sh_prelude.h $(srcinc)/sh_static.h 1629 sh_async.o: $(srcsrc)/sh_async.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_calls.h $(srcinc)/sh_error.h -
trunk/aclocal.m4
r1 r18 1202 1202 ])dnl 1203 1203 1204 dnl checks for a known 64 bit programming environment 1205 dnl AC_RUN_IFELSE(PROGRAM, 1206 dnl [ACTION-IF-TRUE], [ACTION-IF-FALSE], 1207 dnl [ACTION-IF-CROSS-COMPILING = RUNTIME-ERROR]) 1208 dnl 1209 AC_DEFUN([SAMHAIN_PRG_ENV],[ 1210 AC_MSG_CHECKING([for a known 64 bit programming environment]) 1211 # Compile and run a program that determines the programming environment 1212 AC_RUN_IFELSE([ 1213 AC_LANG_SOURCE([[ 1214 #include <stdio.h> 1215 int main(int argc,char **argv) 1216 { 1217 if (argc > 1) { 1218 #if defined(__arch64__) 1219 printf("__arch64__\n"); 1220 #elif defined(__ia64__) 1221 printf("__ia64__\n"); 1222 #elif defined(__x86_64__) 1223 printf("__x86_64__\n"); 1224 #elif defined(__LP64__) 1225 printf("__LP64__\n"); 1226 #elif defined(__64BIT__) 1227 printf("__64BIT__\n"); 1228 #elif defined(_LP64) 1229 printf("_LP64\n"); 1230 #elif defined(_M_IA64) 1231 printf("_M_IA64\n"); 1232 #elif defined(_MIPS_SZLONG) && (_MIPS_SZLONG == 64) 1233 printf("_MIPS_64\n"); 1234 #else 1235 choke me 1236 #endif 1237 } 1238 return 0; 1239 } 1240 ]]) 1241 ],[ 1242 # Program compiled and ran, so get version by adding argument. 1243 samhain_prg_ENV=`./conftest$ac_exeext x` 1244 samhain_64=yes 1245 AC_MSG_RESULT([$samhain_prg_ENV]) 1246 ],[ 1247 AC_MSG_RESULT([none]) 1248 ],[ 1249 AC_MSG_RESULT([none]) 1250 ]) 1251 ])dnl 1252 1253 AC_DEFUN([SAMHAIN_X86_64],[ 1254 AC_MSG_CHECKING([for x86_64]) 1255 AC_TRY_RUN([ 1256 int main() { 1257 __asm__ volatile ( 1258 "movq %rax, %rax" 1259 ); 1260 return 0; 1261 } 1262 ], 1263 [ 1264 AC_MSG_RESULT(yes) 1265 samhain_64=yes 1266 tiger_src=sh_tiger1_64.c 1267 AC_DEFINE([TIGER_OPT_ASM],1,[Define to use tiger x86_64 optimized assembly]) 1268 ], 1269 [ 1270 AC_MSG_RESULT([no]) 1271 ],[ 1272 AC_MSG_RESULT([no]) 1273 ]) 1274 ])dnl 1275 1276 1277 AC_DEFUN([SAMHAIN_64],[ 1278 samhain_64=no 1279 tiger_src=sh_tiger1.c 1280 # 1281 # if sizeof(unsigned long) = 4, try compiler macros for 64bit 1282 # 1283 if test "x$ac_cv_sizeof_unsigned_long" = x4; then 1284 if test "x$ac_cv_sizeof_unsigned_long_long" = x8; then 1285 SAMHAIN_PRG_ENV 1286 if test "x$samhain_64" = xyes; then 1287 tiger_src=sh_tiger1_64.c 1288 fi 1289 # 1290 # if GCC and __i386__, use precompiled assembler 1291 # 1292 if test "x$GCC" = xyes; then 1293 AC_MSG_CHECKING([for i386]) 1294 samhain_i386=no 1295 touch conf_foo.h 1296 $CC -E -dM conf_foo.h | egrep '__i386__' >/dev/null 2>&1 && samhain_i386=yes 1297 rm -f conf_foo.h 1298 if test "x$samhain_i386" = xyes; then 1299 tiger_src=sh_tiger1.s 1300 AC_DEFINE([TIGER_32_BIT_S],1,[Define to use tiger 32 bit i386 assembler]) 1301 fi 1302 AC_MSG_RESULT([$samhain_i386]) 1303 fi 1304 # 1305 # 1306 # 1307 else 1308 samhain_64=no 1309 tiger_src=sh_tiger1.c 1310 fi 1311 else 1312 # 1313 # sizeof(unsigned long) = 8 1314 # 1315 tiger_src=sh_tiger1_64.c 1316 samhain_64=yes 1317 # 1318 # check for x86_64 (enables assembly optimizations) 1319 # 1320 if test "x$GCC" = xyes; then 1321 SAMHAIN_X86_64 1322 fi 1323 fi 1324 if test "x$samhain_64" = xyes; then 1325 AC_DEFINE([TIGER_64_BIT],1,[Define to use tiger 64 bit implementation]) 1326 fi 1327 AC_MSG_CHECKING([for 64 bit environment]) 1328 AC_MSG_RESULT([$samhain_64]) 1329 AC_MSG_CHECKING([for tiger source to use]) 1330 AC_MSG_RESULT([$tiger_src]) 1331 AC_SUBST(tiger_src) 1332 ])dnl 1333 1334 1204 1335 dnl Autoconf macros for libprelude 1205 1336 dnl $id$ -
trunk/configure.ac
r5 r18 37 37 dnl start 38 38 dnl 39 AM_INIT_AUTOMAKE(samhain, 2. 1.1a)39 AM_INIT_AUTOMAKE(samhain, 2.2.0rc1) 40 40 AC_CANONICAL_HOST 41 41 … … 439 439 fi 440 440 441 dnl 442 dnl check for 64 bit programming environment 443 dnl 444 SAMHAIN_64 445 446 441 447 dnl ***************************************** 442 448 dnl checks for structures … … 651 657 LIBWRAP_INC="" 652 658 AC_ARG_WITH(libwrap, 653 [ --with-libwrap[=PATH]Compile in libwrap (TCP Wrappers) support],659 [ --with-libwrap[=PATH] Compile in libwrap (TCP Wrappers) support], 654 660 [ AC_MSG_RESULT($withval) 655 661 case "$withval" in … … 711 717 712 718 AC_ARG_WITH(libprelude-prefix, 713 [ --with-libprelude-prefix=PFX 719 [ --with-libprelude-prefix=PFX Prefix where libprelude is installed (optional)], 714 720 libprelude_config_prefix="$withval", libprelude_config_prefix="") 715 721 716 722 AC_MSG_CHECKING(whether to use prelude) 717 723 AC_ARG_WITH(prelude, 718 [ --with-prelude Prelude IDS support [[no]]],724 [ --with-prelude Prelude IDS support [[no]]], 719 725 [ 720 726 if test "x${withval}" = "xno"; then … … 1156 1162 1157 1163 AC_ARG_WITH(console, 1158 [ --with-console=PATH set path to console device [[/dev/console]]],1164 [ --with-console=PATH set path to console device [[/dev/console]]], 1159 1165 [ 1160 1166 if test "x${withval}" != xno; then … … 1165 1171 1166 1172 AC_ARG_WITH(altconsole, 1167 [ --with-altconsole=PATH set path to second console device [[none]]],1173 [ --with-altconsole=PATH set path to second console device [[none]]], 1168 1174 [ 1169 1175 if test "x${withval}" != xno; then … … 1177 1183 1178 1184 AC_ARG_WITH(timeserver, 1179 [ --with-timeserver=HOST set host address for time server [[none]]],1185 [ --with-timeserver=HOST set host address for time server [[none]]], 1180 1186 [ 1181 1187 if test "x${withval}" != xno; then … … 1190 1196 1191 1197 AC_ARG_WITH(alttimeserver, 1192 [ --with-alttimeserver=HOST set address for backup time server [[none]]],1198 [ --with-alttimeserver=HOST set address for backup time server [[none]]], 1193 1199 [ 1194 1200 if test "x${withval}" != xno; then … … 1212 1218 1213 1219 AC_ARG_ENABLE(mounts-check, 1214 [ --enable-mounts-check 1220 [ --enable-mounts-check check mount options on filesystems [[no]]], 1215 1221 [ 1216 1222 if test "x${enable_mounts_check}" = xyes; then … … 1221 1227 1222 1228 AC_ARG_ENABLE(userfiles, 1223 [ --enable-userfiles 1229 [ --enable-userfiles check for users' config files [[no]]], 1224 1230 [ 1225 1231 if test "x${enableval}" = "xyes"; then … … 1648 1654 sh_syscalltable="0x0" 1649 1655 AC_ARG_ENABLE(khide, 1650 [ --enable-khide=SYSTEM_MAP 1656 [ --enable-khide=SYSTEM_MAP use kernel module to hide (Linux only)[[/boot/System.map]]], 1651 1657 [ 1652 1658 if test "x${enable_khide}" != xno; then … … 1750 1756 sh_libkvm="" 1751 1757 AC_ARG_WITH(kcheck, 1752 [ --with-kcheck =SYSTEM_MAP check Linuxkernel integrity [[/boot/System.map]]],1758 [ --with-kcheck[[=SYSTEM_MAP]] check Linux/FreeBSD/OpenBSD kernel integrity [[/boot/System.map]]], 1753 1759 [ 1754 1760 if test "x${withval}" != "xno"; then … … 1988 1994 do 1989 1995 case ${sh_item} in 1996 *@localhost) 1997 ;; 1990 1998 *@*.*) 1991 1999 sh_tmp=`echo ${sh_item} | awk '{ if ($1 ~ [/^[a-zA-Z0-9][a-zA-Z0-9\-_\.]*@[a-zA-Z0-9\-\.]+\.([a-zA-Z]+|[0-9]+)$/]) {print 1; } else { print 0}}'` -
trunk/depend.dep
r1 r18 58 58 sh_prelink.o: $(srcsrc)/sh_prelink.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_tiger.h $(srcinc)/sh_extern.h $(srcinc)/sh_utils.h $(srcinc)/sh_unix.h 59 59 sh_static.o: $(srcsrc)/sh_static.c Makefile config_xor.h 60 sh_prelude_old.o: $(srcsrc)/sh_prelude_old.c Makefile config_xor.h $(srcinc)/slib.h $(srcinc)/sh_mem.h $(srcinc)/sh_cat.h $(srcinc)/sh_error_min.h $(srcinc)/sh_prelude.h $(srcinc)/sh_static.h 60 61 kern_head.o: $(srcsrc)/kern_head.c Makefile config.h $(srcinc)/kern_head.h $(srcinc)/kern_head.h 61 sh_ prelude_old.o: $(srcsrc)/sh_prelude_old.c Makefile config_xor.h $(srcinc)/slib.h $(srcinc)/sh_mem.h $(srcinc)/sh_cat.h $(srcinc)/sh_error_min.h $(srcinc)/sh_prelude.h $(srcinc)/sh_static.h62 sh_async.o: $(srcsrc)/sh_async.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_calls.h $(srcinc)/sh_error.h -
trunk/depend.sum
r1 r18 1 11524979881 3476546078 -
trunk/docs/Changelog
r5 r18 1 2.2.0: 2 * added a bit of unit testing 3 * improved the windows howto according to suggestions by 4 Jorge Morgado 5 * minor optimizations in various places 6 * optimized implementation of tiger checksum algorithm 7 * read in 64k blocks (faster than 4k) 8 * sh_unix.c, sh_hash.c: support file flags on *BSD, update Linux 9 file attribute code 10 * kern_head: fix compilation of kernel check module on OpenBSD 11 * updated samhainrc.linux, samhainrc.freebsd 12 * sh_unix.c: fix setrlimit (RLIMIT_NOFILE, ..) 13 * sh_files.c: fix missing use of flag_err_info 14 * sh_tiger0.c: remove repetitive use of mlock 15 * slib.c: remove fcntl's from sl_read_timeout (caller sets O_NONBLOCK), 16 add function sl_read_timeout_prep 17 18 2.1.2 (10-01-2006): 19 * fix startup error with combination of gpg+prelude 1 20 2 21 2.1.1a (22-12-2005): -
trunk/docs/HOWTO-samhain-on-windows.html
r1 r18 135 135 <b>Cygwin</b> POSIX emulation layer, and how to install it as a service. 136 136 These instructions have been written by Kris Dom, 137 who has tested this on WinXP Professional. 137 who has tested this on WinXP Professional, with additions by Geries Handal 138 and Jorge Morgado. 138 139 </p> 139 140 <div class="block"> … … 150 151 logging) because Interix does not provide some of the required functionality 151 152 to build the email module. This issue should be fixed as of samhain 152 version 2.0.7 (not tested).<br />[Based on information kindly provided by Geries Handal]. 153 version 2.0.7 (not tested).<br /> 154 [Based on information kindly provided by Geries Handal]. 153 155 </p> 154 156 </div> … … 192 194 </li> 193 195 </ul> 196 <div class="block"> 197 <p> 198 You don't need to download and install All packages. It is enough to keep 199 the Default and then add the following additional packages: 200 </p> 201 <p> 202 Category Devel -> gcc: C compiler upgrade helper<br/> 203 Category Devel -> make: The GNU version of the 'make' utility<br/> 204 Category Libs -> minires: A simple synchronous non caching stub resolver<br/> 205 </p> 206 <p> 207 When selecting these packages, Cygwin installer will automatically add 208 other packages based on their dependencies. 209 The package minires is only necessary for a minimal Cygwin installation 210 (below). [Kindly pointed out by Jorge Morgado]. 211 </p> 212 </div> 194 213 195 214 <h3>Cygwin installation</h3> … … 301 320 </li> 302 321 </ul> 322 </li> 323 <li> 324 Files needed from c:\Cygwin\bin to create the /etc/passwd and /etc/group files: 325 <ul> 326 <li> 327 mkpasswd.exe 328 </li> 329 <li> 330 mkgroup.exe 331 </li> 332 </ul> 333 <p> 334 To generate these files on a minimal Cygwin installation execute - on a 335 Windows Command Prompt: 336 </p><p> 337 <tt>mkdir c:\etc</tt><br /> 338 <tt>path\to\mkpasswd.exe -l > c:\etc\passwd</tt><br /> 339 <tt>path\to\mkgroup.exe -l > c:\etc\group</tt> 340 </p><p> 341 IMPORTANT NOTE: You should re-create these two files, each time the 342 Windows users and groups accounts database changes. Failing to do this 343 might generate critical log messages (depending on your configuration 344 file). 345 </p> 303 346 </li> 304 347 <li> … … 331 374 </li> 332 375 <li>Under the newly created "Parameters" key, add a new String 333 value called "Application s".<br />334 The value for "Application s"376 value called "Application".<br /> 377 The value for "Application" 335 378 should be "c:\usr\local\sbin\samhain.exe".</li> 336 379 </ul> … … 348 391 </li> 349 392 </ul> 393 <p> 394 Also see <a href="http://support.microsoft.com/kb/q137890/">http://support.microsoft.com/kb/q137890/</a> for information regarding the creation of a 395 user-defined service. 396 </p> 350 397 <p> 351 398 Note: the first time I tried to install samhain as an NT service, I first … … 354 401 Samhain as a service. 355 402 </p> 403 404 405 <h2>Troubleshooting samhain</h2> 406 407 <p> 408 [Tip from Jorge Morgado] If you, like me, have a Windows server not part of any domain and (for 409 security reasons) you even turn off DNS resolution, you might probably get 410 the following error when initializing the baseline database: 411 </p> 412 <pre> 413 --------- sh_unix.c --- 1487 --------- 414 According to uname, your nodename is yourcomputername, but your resolver 415 library cannot resolve this nodename to a FQDN. 416 Rather, it resolves this to yourcomputername. 417 For more information, see the entry about self-resolving under 418 'Most frequently' in the FAQ that you will find in the docs/ subdirectory 419 ---------------------------------------------- 420 </pre> 421 <p> 422 To fix this problem open the Registry Editor and create the following 423 entries under the key 424 HKLM\System\CurrentControlSet\Services\Tcpip\Parameters 425 </p> 426 <p> 427 <tt> 428 Name: Domain<br/> 429 Type: REG_SZ<br/> 430 Data: your.domain.name 431 </tt> 432 </p><p> 433 <tt> 434 Name: NV Domain<br/> 435 Type: REG_SZ<br/> 436 Data: your.domain.name 437 </tt> 438 </p><p> 439 The NV Domain registry value contains the computer's primary DNS suffix 440 while the Domain registry value contains the computer's primary DNS 441 domain. This will make the warning message go away. 442 </p> 356 443 </div> 357 444 </body> -
trunk/docs/README.UPGRADE
r1 r18 1 since 2.1.0: update and daemon mode can be combined 2 3 -- this implies that '-t update' will start a daemon process if running as 4 daemon is the default specified in the config file. use '--foreground' 5 to avoid starting a daemon process 6 7 1 8 2 9 from 1.7.x to 1.8.x: client/server encryption protocol has been enhanced -
trunk/docs/TODO
r1 r18 1 1 2 Wishlist:3 4 - yule -> yule relay5 - partial checksum of growing logfiles6 -
trunk/include/samhain.h
r1 r18 60 60 */ 61 61 #define PW_LEN 8 62 63 /* Buffer for privileged content.64 */65 #define PRIV_MAX 409666 62 67 63 #undef GOOD -
trunk/samhainrc.linux
r14 r18 177 177 dir = -1/var/tmp 178 178 dir = -1/var/lib/texmf 179 dir = -1/var/lib/scrollkeeper 180 179 181 180 182 [Attributes] … … 229 231 file = /var/log/*.old 230 232 file = /var/log/*/*.[0-9].gz 233 file = /var/log/*/*.[0-9][0-9].gz 231 234 file = /var/log/*/*.log.[0-9] 232 235 -
trunk/src/samhain.c
r1 r18 1075 1075 * 1076 1076 *******************************************************/ 1077 #if !defined(SH_CUTEST) 1077 1078 int main(int argc, char * argv[]) 1079 #else 1080 int undef_main(int argc, char * argv[]) 1081 #endif 1078 1082 { 1079 1083 #if defined(INET_SYSLOG) -
trunk/src/sh_database.c
r13 r18 1064 1064 } 1065 1065 1066 /* Read in defaults from /etc/my.cnf and associated files, 1067 * suggested by arjones at simultan dyndns org 1068 * see: - http://dev.mysql.com/doc/refman/5.0/en/option-files.html 1069 * for the my.cnf format, 1070 * - http://dev.mysql.com/doc/refman/5.0/en/mysql-options.html 1071 * for possible options 1072 * We don't check the return value because it's useless (failure due 1073 * to lack of access permission is not reported). 1074 */ 1075 mysql_options(db_conn, MYSQL_READ_DEFAULT_GROUP, _("samhain")); 1076 1066 1077 status = 0; 1067 1078 -
trunk/src/sh_hash.c
r10 r18 396 396 static int hashfunc(char *s) 397 397 { 398 unsigned n = 0;398 unsigned int n = 0; 399 399 400 400 for ( ; *s; s++) 401 401 n = 31 * n + *s; 402 return n & 0xFFFF;/* % TABSIZE*/; 402 403 return n & (TABSIZE - 1); /* % TABSIZE */; 403 404 } 404 405 -
trunk/src/sh_tiger0.c
r11 r18 25 25 #include "sh_utils.h" 26 26 27 #if defined(HAVE_LONG_64) || defined(HAVE_LONG_LONG_64) 27 #define PRIV_MAX 32768 28 29 #if defined(TIGER_64_BIT) 28 30 #if defined(HAVE_LONG_64) 29 31 typedef unsigned long int word64; 32 #elif defined(HAVE_LONG_LONG_64) 33 typedef unsigned long long int word64; 30 34 #else 31 typedef unsigned long long int word64; 35 #error No 64 bit type found ! 32 36 #endif 33 37 #endif … … 46 50 #define GPGFORMAT (_("%08X %08X %08X %08X %08X %08X")) 47 51 #else 48 #error No 32 b ytetype found !52 #error No 32 bit type found ! 49 53 #endif 50 54 … … 54 58 #define FIL__ _("sh_tiger0.c") 55 59 56 #if defined( HAVE_LONG_64) || defined(HAVE_LONG_LONG_64)57 /* #ifdef HAVE_LONG_64 */ 60 #if defined(TIGER_64_BIT) 61 58 62 void tiger_t(word64 *str, word64 length, word64 * res); 59 63 void tiger(word64 *str, word64 length, word64 * res); … … 97 101 static sh_byte buffer[PRIV_MAX + 72]; 98 102 99 #if defined(HAVE_LONG_64) || defined(HAVE_LONG_LONG_64) 100 /* #ifdef HAVE_LONG_64 */ 103 #if defined(TIGER_64_BIT) 101 104 static 102 105 word64 * sh_tiger_hash_val (char * filename, TigerType what, … … 114 117 char * tmp; 115 118 sh_byte * bptr; 116 /* sh_byte buffer[PRIV_MAX + 72]; */117 119 sh_byte bbuf[64]; 118 120 … … 131 133 #endif 132 134 133 #if defined(HAVE_LONG_64) || defined(HAVE_LONG_LONG_64) 134 /* #ifdef HAVE_LONG_64 */ 135 #if defined(TIGER_64_BIT) 135 136 #define TIGER_CAST (word64*) 136 137 static word64 res[3]; … … 254 255 } 255 256 256 if (blk < 64) /* this must be (PRIV_MAX / 64) */257 if (blk < (PRIV_MAX / 64)) /* this must be (PRIV_MAX / 64) */ 257 258 break; 258 259 … … 359 360 bptr = buffer; 360 361 361 memcpy(bptr, bbuf, 64); bptr += 64; 362 memcpy(bptr, bbuf, 64); bptr += 64; 363 memcpy(bptr, buffer, 128); bptr += 128; 364 memcpy(bptr, buffer, 256); bptr += 256; 365 memcpy(bptr, buffer, 512); bptr += 512; 366 memcpy(bptr, buffer,1024); bptr += 1024; 367 memcpy(bptr, buffer,2048); 362 memcpy(bptr, bbuf, 64); bptr += 64; 363 memcpy(bptr, bbuf, 64); bptr += 64; 364 memcpy(bptr, buffer, 128); bptr += 128; 365 memcpy(bptr, buffer, 256); bptr += 256; 366 memcpy(bptr, buffer, 512); bptr += 512; 367 memcpy(bptr, buffer, 1024); bptr += 1024; 368 memcpy(bptr, buffer, 2048); bptr += 2048; 369 memcpy(bptr, buffer, 4096); bptr += 4096; 370 memcpy(bptr, buffer, 8192); bptr += 8192; 371 memcpy(bptr, buffer,16384); 368 372 369 373 if (what == TIGER_FILE) … … 814 818 MSG_E_SUBGEN, _("Not TIGER_FD"), 815 819 _("sh_tiger_md5_hash")); 820 out[0] = '\0'; 816 821 return out; 817 822 } … … 1328 1333 MSG_E_SUBGEN, _("Not TIGER_FD"), 1329 1334 _("sh_tiger_sha1_hash")); 1335 out[0] = '\0'; 1330 1336 return out; 1331 1337 } … … 1410 1416 unsigned long Length, int timeout) 1411 1417 { 1412 #if defined(HAVE_LONG_64) || defined(HAVE_LONG_LONG_64) 1413 /* #ifdef HAVE_LONG_64 */ 1418 #if defined(TIGER_64_BIT) 1414 1419 word64 * res; 1415 1420 #else … … 1425 1430 { 1426 1431 /*@-bufferoverflowhigh -formatconst@*/ 1427 #if defined(HAVE_LONG_64) || defined(HAVE_LONG_LONG_64) 1428 /* #ifdef HAVE_LONG_64 */ 1432 #if defined(TIGER_64_BIT) 1429 1433 sprintf(out, /* known to fit */ 1430 1434 MYFORMAT, … … 1461 1465 char * out; 1462 1466 char outhash[48+6+1]; 1463 #if defined(HAVE_LONG_64) || defined(HAVE_LONG_LONG_64) 1464 /* #ifdef HAVE_LONG_64 */ 1467 #if defined(TIGER_64_BIT) 1465 1468 word64 * res; 1466 1469 #else … … 1474 1477 { 1475 1478 /*@-bufferoverflowhigh -formatconst@*/ 1476 #if defined(HAVE_LONG_64) || defined(HAVE_LONG_LONG_64) 1477 /* #ifdef HAVE_LONG_64 */ 1479 #if defined(TIGER_64_BIT) 1478 1480 sprintf(outhash, /* known to fit */ 1479 1481 GPGFORMAT, … … 1530 1532 unsigned long Length) 1531 1533 { 1532 #if defined(HAVE_LONG_64) || defined(HAVE_LONG_LONG_64) 1533 /* #ifdef HAVE_LONG_64 */ 1534 #if defined(TIGER_64_BIT) 1534 1535 word64 * res; 1535 1536 #else … … 1548 1549 if (res != NULL) 1549 1550 { 1550 #if defined(HAVE_LONG_64) || defined(HAVE_LONG_LONG_64) 1551 /* #ifdef HAVE_LONG_64 */ 1551 #if defined(TIGER_64_BIT) 1552 1552 out[0] = (UINT32)(res[0]>>32); 1553 1553 out[1] = (UINT32)(res[0]); -
trunk/src/sh_tiger1.c
r1 r18 5 5 #include "config_xor.h" 6 6 7 8 #if !defined(HAVE_LONG_64) && !defined(HAVE_LONG_LONG_64) 7 /* we already inline in the function used for file checksums */ 8 /* #define UNROLL_COMPRESS */ 9 #undef UNROLL_COMPRESS 10 11 #if !defined(TIGER_64_BIT) 9 12 10 13 /* Tiger: A Fast New Hash Function … … 37 40 typedef unsigned short sh_word32; 38 41 #else 39 #error No 32 b ytetype found !42 #error No 32 bit type found ! 40 43 #endif 41 44 … … 46 49 #define BIG_ENDIAN 47 50 #endif 48 49 /* NOTE that this code is NOT FULLY OPTIMIZED for any */50 /* machine. Assembly code might be much faster on some */51 /* machines, especially if the code is compiled with */52 /* gcc. */53 51 54 52 /* The number of passes of the hash function. */ … … 65 63 #define t4 (tiger_table+256*3) 66 64 67 #define s h_sub64(s0, s1, p0, p1) \65 #define sub64(s0, s1, p0, p1) \ 68 66 temps0 = (p0); \ 69 67 tcarry = s0 < temps0; \ … … 71 69 s1 -= (p1) + tcarry; 72 70 73 #define sh_add64(s0, s1, p0, p1) \71 #define add64(s0, s1, p0, p1) \ 74 72 temps0 = (p0); \ 75 73 s0 += temps0; \ … … 77 75 s1 += (p1) + tcarry; 78 76 79 #define sh_xor64(s0, s1, p0, p1) \77 #define xor64(s0, s1, p0, p1) \ 80 78 s0 ^= (p0); \ 81 79 s1 ^= (p1); 82 80 83 #define sh_mul5(s0, s1) \81 #define mul5(s0, s1) \ 84 82 tempt0 = s0<<2; \ 85 83 tempt1 = (s1<<2)|(s0>>30); \ 86 sh_add64(s0, s1, tempt0, tempt1);87 88 #define sh_mul7(s0, s1) \84 add64(s0, s1, tempt0, tempt1); 85 86 #define mul7(s0, s1) \ 89 87 tempt0 = s0<<3; \ 90 88 tempt1 = (s1<<3)|(s0>>29); \ 91 s h_sub64(tempt0, tempt1, s0, s1); \89 sub64(tempt0, tempt1, s0, s1); \ 92 90 s0 = tempt0; \ 93 91 s1 = tempt1; 94 92 95 #define sh_mul9(s0, s1) \93 #define mul9(s0, s1) \ 96 94 tempt0 = s0<<3; \ 97 95 tempt1 = (s1<<3)|(s0>>29); \ 98 sh_add64(s0, s1, tempt0, tempt1);99 100 #define s h_save_abc \96 add64(s0, s1, tempt0, tempt1); 97 98 #define save_abc \ 101 99 aa0 = a0; \ 102 100 aa1 = a1; \ … … 106 104 cc1 = c1; 107 105 108 #define sh_round(a0,a1,b0,b1,c0,c1,x0,x1,mul) \109 sh_xor64(c0, c1, x0, x1); \106 #define roundX(a0,a1,b0,b1,c0,c1,x0,x1) \ 107 xor64(c0, c1, x0, x1); \ 110 108 temp0 = t1[((c0)>>(0*8))&0xFF][0] ; \ 111 109 temp1 = t1[((c0)>>(0*8))&0xFF][1] ; \ … … 116 114 temp0 ^= t4[((c1)>>(2*8))&0xFF][0] ; \ 117 115 temp1 ^= t4[((c1)>>(2*8))&0xFF][1] ; \ 118 s h_sub64(a0, a1, temp0, temp1); \116 sub64(a0, a1, temp0, temp1); \ 119 117 temp0 = t4[((c0)>>(1*8))&0xFF][0] ; \ 120 118 temp1 = t4[((c0)>>(1*8))&0xFF][1] ; \ … … 125 123 temp0 ^= t1[((c1)>>(3*8))&0xFF][0] ; \ 126 124 temp1 ^= t1[((c1)>>(3*8))&0xFF][1] ; \ 127 sh_add64(b0, b1, temp0, temp1); \ 128 if((mul)==5) \ 129 {sh_mul5(b0, b1);} \ 130 else \ 131 if((mul)==7) \ 132 {sh_mul7(b0, b1);} \ 133 else \ 134 {sh_mul9(b0, b1)}; 135 136 #define sh_pass(a0,a1,b0,b1,c0,c1,mul) \ 137 sh_round(a0,a1,b0,b1,c0,c1,x00,x01,mul); \ 138 sh_round(b0,b1,c0,c1,a0,a1,x10,x11,mul); \ 139 sh_round(c0,c1,a0,a1,b0,b1,x20,x21,mul); \ 140 sh_round(a0,a1,b0,b1,c0,c1,x30,x31,mul); \ 141 sh_round(b0,b1,c0,c1,a0,a1,x40,x41,mul); \ 142 sh_round(c0,c1,a0,a1,b0,b1,x50,x51,mul); \ 143 sh_round(a0,a1,b0,b1,c0,c1,x60,x61,mul); \ 144 sh_round(b0,b1,c0,c1,a0,a1,x70,x71,mul); 145 146 #define sh_key_schedule \ 147 sh_sub64(x00, x01, x70^0xA5A5A5A5, x71^0xA5A5A5A5); \ 148 sh_xor64(x10, x11, x00, x01); \ 149 sh_add64(x20, x21, x10, x11); \ 150 sh_sub64(x30, x31, x20^((~x10)<<19), ~x21^(((x11)<<19)|((x10)>>13))); \ 151 sh_xor64(x40, x41, x30, x31); \ 152 sh_add64(x50, x51, x40, x41); \ 153 sh_sub64(x60, x61, ~x50^(((x40)>>23)|((x41)<<9)), x51^((~x41)>>23)); \ 154 sh_xor64(x70, x71, x60, x61); \ 155 sh_add64(x00, x01, x70, x71); \ 156 sh_sub64(x10, x11, x00^((~x70)<<19), ~x01^(((x71)<<19)|((x70)>>13))); \ 157 sh_xor64(x20, x21, x10, x11); \ 158 sh_add64(x30, x31, x20, x21); \ 159 sh_sub64(x40, x41, ~x30^(((x20)>>23)|((x21)<<9)), x31^((~x21)>>23)); \ 160 sh_xor64(x50, x51, x40, x41); \ 161 sh_add64(x60, x61, x50, x51); \ 162 sh_sub64(x70, x71, x60^0x89ABCDEF, x61^0x01234567); 163 164 #define sh_feedforward \ 165 sh_xor64(a0, a1, aa0, aa1); \ 166 sh_sub64(b0, b1, bb0, bb1); \ 167 sh_add64(c0, c1, cc0, cc1); 168 169 #ifdef UNROLL_COMPRESS 170 #define sh_compress \ 171 sh_save_abc \ 172 sh_pass(a0,a1,b0,b1,c0,c1,5); \ 173 sh_key_schedule; \ 174 sh_pass(c0,c1,a0,a1,b0,b1,7); \ 175 sh_key_schedule; \ 176 sh_pass(b0,b1,c0,c1,a0,a1,9); \ 177 for(pass_no=3; pass_no<PASSES; pass_no++) { \ 178 sh_key_schedule \ 179 sh_pass(a0,a1,b0,b1,c0,c1,9); \ 180 tmpa=a0; a0=c0; c0=b0; b0=tmpa; \ 181 tmpa=a1; a1=c1; c1=b1; b1=tmpa;} \ 182 sh_feedforward 183 #else 184 #define sh_compress \ 185 sh_save_abc \ 186 for(pass_no=0; pass_no<PASSES; pass_no++) { \ 187 if(pass_no != 0) {sh_key_schedule} \ 188 sh_pass(a0,a1,b0,b1,c0,c1,(pass_no==0?5:pass_no==1?7:9)) \ 189 tmpa=a0; a0=c0; c0=b0; b0=tmpa; \ 190 tmpa=a1; a1=c1; c1=b1; b1=tmpa;} \ 191 sh_feedforward 192 #endif 125 add64(b0, b1, temp0, temp1); 126 127 128 #define round5(a0,a1,b0,b1,c0,c1,x0,x1) \ 129 roundX(a0,a1,b0,b1,c0,c1,x0,x1); \ 130 mul5(b0, b1); 131 132 #define round7(a0,a1,b0,b1,c0,c1,x0,x1) \ 133 roundX(a0,a1,b0,b1,c0,c1,x0,x1); \ 134 mul7(b0, b1); 135 136 #define round9(a0,a1,b0,b1,c0,c1,x0,x1) \ 137 roundX(a0,a1,b0,b1,c0,c1,x0,x1); \ 138 mul9(b0, b1); 139 140 141 /* mixed with key_schedule 142 */ 143 #define pass5(a0,a1,b0,b1,c0,c1) \ 144 round5(a0,a1,b0,b1,c0,c1,x00,x01); \ 145 sub64(x00, x01, x70^0xA5A5A5A5, x71^0xA5A5A5A5); \ 146 round5(b0,b1,c0,c1,a0,a1,x10,x11); \ 147 xor64(x10, x11, x00, x01); \ 148 round5(c0,c1,a0,a1,b0,b1,x20,x21); \ 149 add64(x20, x21, x10, x11); \ 150 round5(a0,a1,b0,b1,c0,c1,x30,x31); \ 151 sub64(x30, x31, x20^((~x10)<<19), ~x21^(((x11)<<19)|((x10)>>13))); \ 152 round5(b0,b1,c0,c1,a0,a1,x40,x41); \ 153 xor64(x40, x41, x30, x31); \ 154 round5(c0,c1,a0,a1,b0,b1,x50,x51); \ 155 add64(x50, x51, x40, x41); \ 156 round5(a0,a1,b0,b1,c0,c1,x60,x61); \ 157 sub64(x60, x61, ~x50^(((x40)>>23)|((x41)<<9)), x51^((~x41)>>23)); \ 158 round5(b0,b1,c0,c1,a0,a1,x70,x71); 159 160 /* mixed with key_schedule 161 */ 162 #define pass7(a0,a1,b0,b1,c0,c1) \ 163 round7(a0,a1,b0,b1,c0,c1,x00,x01); \ 164 sub64(x00, x01, x70^0xA5A5A5A5, x71^0xA5A5A5A5); \ 165 round7(b0,b1,c0,c1,a0,a1,x10,x11); \ 166 xor64(x10, x11, x00, x01); \ 167 round7(c0,c1,a0,a1,b0,b1,x20,x21); \ 168 add64(x20, x21, x10, x11); \ 169 round7(a0,a1,b0,b1,c0,c1,x30,x31); \ 170 sub64(x30, x31, x20^((~x10)<<19), ~x21^(((x11)<<19)|((x10)>>13))); \ 171 round7(b0,b1,c0,c1,a0,a1,x40,x41); \ 172 xor64(x40, x41, x30, x31); \ 173 round7(c0,c1,a0,a1,b0,b1,x50,x51); \ 174 add64(x50, x51, x40, x41); \ 175 round7(a0,a1,b0,b1,c0,c1,x60,x61); \ 176 sub64(x60, x61, ~x50^(((x40)>>23)|((x41)<<9)), x51^((~x41)>>23)); \ 177 round7(b0,b1,c0,c1,a0,a1,x70,x71); 178 179 /* mixed with key_schedule 180 */ 181 #define pass9(a0,a1,b0,b1,c0,c1) \ 182 round9(a0,a1,b0,b1,c0,c1,x00,x01); \ 183 sub64(x00, x01, x70^0xA5A5A5A5, x71^0xA5A5A5A5); \ 184 round9(b0,b1,c0,c1,a0,a1,x10,x11); \ 185 xor64(x10, x11, x00, x01); \ 186 round9(c0,c1,a0,a1,b0,b1,x20,x21); \ 187 add64(x20, x21, x10, x11); \ 188 round9(a0,a1,b0,b1,c0,c1,x30,x31); \ 189 sub64(x30, x31, x20^((~x10)<<19), ~x21^(((x11)<<19)|((x10)>>13))); \ 190 round9(b0,b1,c0,c1,a0,a1,x40,x41); \ 191 xor64(x40, x41, x30, x31); \ 192 round9(c0,c1,a0,a1,b0,b1,x50,x51); \ 193 add64(x50, x51, x40, x41); \ 194 round9(a0,a1,b0,b1,c0,c1,x60,x61); \ 195 sub64(x60, x61, ~x50^(((x40)>>23)|((x41)<<9)), x51^((~x41)>>23)); \ 196 round9(b0,b1,c0,c1,a0,a1,x70,x71); 197 198 #define key_schedule \ 199 xor64(x70, x71, x60, x61); \ 200 add64(x00, x01, x70, x71); \ 201 sub64(x10, x11, x00^((~x70)<<19), ~x01^(((x71)<<19)|((x70)>>13))); \ 202 xor64(x20, x21, x10, x11); \ 203 add64(x30, x31, x20, x21); \ 204 sub64(x40, x41, ~x30^(((x20)>>23)|((x21)<<9)), x31^((~x21)>>23)); \ 205 xor64(x50, x51, x40, x41); \ 206 add64(x60, x61, x50, x51); \ 207 sub64(x70, x71, x60^0x89ABCDEF, x61^0x01234567); 208 209 #define feedforward \ 210 xor64(a0, a1, aa0, aa1); \ 211 sub64(b0, b1, bb0, bb1); \ 212 add64(c0, c1, cc0, cc1); 213 214 #define compress \ 215 pass5(a0,a1,b0,b1,c0,c1); \ 216 key_schedule; \ 217 pass7(c0,c1,a0,a1,b0,b1); \ 218 key_schedule; \ 219 pass9(b0,b1,c0,c1,a0,a1); \ 220 feedforward 193 221 194 222 #define tiger_compress_macro(str, state) \ 195 223 { \ 196 register sh_word32 a0, a1, b0, b1, c0, c1 , tmpa; \224 register sh_word32 a0, a1, b0, b1, c0, c1; \ 197 225 sh_word32 aa0, aa1, bb0, bb1, cc0, cc1; \ 198 226 sh_word32 x00, x01, x10, x11, x20, x21, x30, x31, \ 199 x40, x41, x50, x51, x60, x61, x70, x71; \ 200 register sh_word32 temp0, temp1, tempt0, tempt1, temps0, tcarry; \ 201 int pass_no; \ 227 x40, x41, x50, x51, x60, x61, x70, x71; \ 228 sh_word32 temp0, temp1, tempt0, tempt1, temps0, tcarry; \ 202 229 \ 203 230 a0 = state[0]; \ … … 208 235 c1 = state[5]; \ 209 236 \ 237 save_abc \ 238 \ 210 239 x00=str[0*2]; x01=str[0*2+1]; x10=str[1*2]; x11=str[1*2+1]; \ 211 240 x20=str[2*2]; x21=str[2*2+1]; x30=str[3*2]; x31=str[3*2+1]; \ … … 213 242 x60=str[6*2]; x61=str[6*2+1]; x70=str[7*2]; x71=str[7*2+1]; \ 214 243 \ 215 sh_compress; \244 compress; \ 216 245 \ 217 246 state[0] = a0; \ … … 223 252 } 224 253 225 #if def UNROLL_COMPRESS254 #if defined(UNROLL_COMPRESS) 226 255 /* The compress function is inlined */ 227 256 #define tiger_compress(str, state) \ 228 257 tiger_compress_macro(((sh_word32*)str), ((sh_word32*)state)) 229 #else 230 /* The compress function is a function */ 258 259 #else 260 231 261 void 232 262 tiger_compress(sh_word32 *str, sh_word32 state[6]) … … 249 279 #ifdef BIG_ENDIAN 250 280 for(j=0; j<64; j++) 251 252 tiger_compress (((sh_word32*)temp), res);253 #else 254 tiger_compress (str, res);281 temp[j^3] = ((sh_byte*)str)[j]; 282 tiger_compress_macro(((sh_word32*)temp), res); 283 #else 284 tiger_compress_macro(str, res); 255 285 #endif 256 286 str += 16; … … 258 288 } 259 289 260 void 261 tiger(sh_word32 *str, sh_word32 length, sh_word32 res[6])290 291 void tiger(sh_word32 *str, sh_word32 length, sh_word32 res[6]) 262 292 { 263 293 register sh_word32 i, j; 264 294 sh_byte temp[64]; 295 296 /* 297 * res[0]=0x89ABCDEF; 298 * res[1]=0x01234567; 299 * res[2]=0x76543210; 300 * res[3]=0xFEDCBA98; 301 * res[4]=0xC3B2E187; 302 * res[5]=0xF096A5B4; 303 */ 265 304 266 305 for(i=length; i>=64; i-=64) … … 307 346 } 308 347 309 #else 310 void dummy_1 (int a) 311 { 312 (void) a; 313 return; 314 } 315 #endif 316 317 318 319 320 321 322 323 324 348 #endif 349 -
trunk/src/sh_tiger1_64.c
r1 r18 5 5 #include "config_xor.h" 6 6 7 #if defined(HAVE_LONG_64) || defined(HAVE_LONG_LONG_64) 8 9 /*@-incondefs -macroparens -macroassign -macroparams -macrostmt @*/ 10 /*@-fixedformalarray +charindex -type -paramuse -predboolint -exportlocal@*/ 7 #if defined(TIGER_64_BIT) 8 9 /* #if defined(HAVE_LONG_64) || defined(HAVE_LONG_LONG_64) */ 10 11 #undef USE_MEMSET 12 11 13 /* Big endian: */ 12 14 #ifdef WORDS_BIGENDIAN 13 15 #define BIG_ENDIAN 14 16 #endif 15 16 17 17 18 /* Tiger: A Fast New Hash Function … … 38 39 #if defined(HAVE_LONG_64) 39 40 typedef unsigned long int word64; 40 #el se41 #elif defined(HAVE_LONG_LONG_64) 41 42 typedef unsigned long long int word64; 43 #else 44 #error No 64 bit type found ! 42 45 #endif 43 46 … … 49 52 typedef unsigned short sh_word32; 50 53 #else 51 #error No 32 b ytetype found !54 #error No 32 bit type found ! 52 55 #endif 53 56 54 57 typedef unsigned char sh_byte; 55 58 56 /* Big endian: 57 #if !(defined(__alpha)||defined(__i386__)||defined(__vax__)) 58 #define BIG_ENDIAN 59 #endif 60 */ 61 62 /* The following macro denotes that an optimization */ 63 /* for Alpha is required. It is used only for */ 64 /* optimization of time. Otherwise it does nothing. */ 65 #ifdef __alpha 66 #define OPTIMIZE_FOR_ALPHA 67 #endif 68 69 /* NOTE that this code is NOT FULLY OPTIMIZED for any */ 70 /* machine. Assembly code might be much faster on some */ 71 /* machines, especially if the code is compiled with */ 72 /* gcc. */ 73 74 /* The number of passes of the hash function. */ 75 /* Three passes are recommended. */ 76 /* Use four passes when you need extra security. */ 77 /* Must be at least three. */ 59 #if defined(TIGER_OPT_ASM) 60 #define TIGER_ASM64_2 1 61 #else 62 #define TIGER_C 1 63 #endif 64 65 /* The number of passes of the hash function. */ 66 /* Three passes are recommended. */ 67 /* Use four passes when you need extra security. */ 68 /* Must be at least three. */ 78 69 #define PASSES 3 79 70 80 71 extern word64 tiger_table[4*256]; 72 73 /* Volatile can help if compiler is smart enough to use memory operand */ 74 static /*volatile*/ const word64 XOR_CONST1=0xA5A5A5A5A5A5A5A5LL; 75 static /*volatile*/ const word64 XOR_CONST2=0x0123456789ABCDEFLL; 81 76 82 77 #define t1 (tiger_table) … … 85 80 #define t4 (tiger_table+256*3) 86 81 82 #define pass_start 83 #define pass_end 84 85 86 87 87 #define save_abc \ 88 aa = a; \ 89 bb = b; \ 90 cc = c; 91 92 #ifdef OPTIMIZE_FOR_ALPHA 93 /* This is the official definition of round */ 94 #define round(a,b,c,x,mul) \ 95 c ^= x; \ 96 a -= t1[((c)>>(0*8))&0xFF] ^ t2[((c)>>(2*8))&0xFF] ^ \ 97 t3[((c)>>(4*8))&0xFF] ^ t4[((c)>>(6*8))&0xFF] ; \ 98 b += t4[((c)>>(1*8))&0xFF] ^ t3[((c)>>(3*8))&0xFF] ^ \ 99 t2[((c)>>(5*8))&0xFF] ^ t1[((c)>>(7*8))&0xFF] ; \ 100 b *= mul; 101 #else 102 /* This code works faster when compiled on 32-bit machines */ 103 /* (but works slower on Alpha) */ 104 #define round(a,b,c,x,mul) \ 105 c ^= x; \ 106 a -= t1[(sh_byte)(c)] ^ \ 107 t2[(sh_byte)(((sh_word32)(c))>>(2*8))] ^ \ 108 t3[(sh_byte)((c)>>(4*8))] ^ \ 109 t4[(sh_byte)(((sh_word32)((c)>>(4*8)))>>(2*8))] ; \ 110 b += t4[(sh_byte)(((sh_word32)(c))>>(1*8))] ^ \ 111 t3[(sh_byte)(((sh_word32)(c))>>(3*8))] ^ \ 112 t2[(sh_byte)(((sh_word32)((c)>>(4*8)))>>(1*8))] ^ \ 113 t1[(sh_byte)(((sh_word32)((c)>>(4*8)))>>(3*8))]; \ 114 b *= mul; 115 #endif 116 117 #define pass(a,b,c,mul) \ 118 round(a,b,c,x0,mul) \ 119 round(b,c,a,x1,mul) \ 120 round(c,a,b,x2,mul) \ 121 round(a,b,c,x3,mul) \ 122 round(b,c,a,x4,mul) \ 123 round(c,a,b,x5,mul) \ 124 round(a,b,c,x6,mul) \ 125 round(b,c,a,x7,mul) 88 aa = a; \ 89 bb = b; \ 90 cc = c; 91 92 #ifdef TIGER_C 93 94 #define BN(x,n) (((x)>>((n)*8))&0xFF) 95 96 97 /* Depending on outer code one of these two can be better*/ 98 #define roundX(a,b,c,x) \ 99 c ^= x; \ 100 a -= t1[BN(c,0)] ^ t2[BN(c,2)] ^ \ 101 t3[BN(c,4)] ^ t4[BN(c,6)] ; \ 102 b += t4[BN(c,1)] ^ t3[BN(c,3)] ^ \ 103 t2[BN(c,5)] ^ t1[BN(c,7)] ; 104 105 #define round5(a,b,c,x) roundX(a,b,c,x) b = b+b*4; 106 #define round7(a,b,c,x) roundX(a,b,c,x) b = b*8-b; 107 #define round9(a,b,c,x) roundX(a,b,c,x) b = b+b*8; 108 109 #endif 110 111 112 #ifdef TIGER_OPT_ASM 113 114 #define MASK0 0xFFL 115 #define MASK8 0xFF00L 116 #define MASK16 0xFF0000L 117 #define MASK32 0xFF00000000LL 118 #define MASK40 0xFF0000000000LL 119 #define MASK48 0xFF000000000000LL 120 121 #define roundstart __asm__ ( 122 123 /* a will be moved into different reg each round 124 * using register substitution feature of GCC asm 125 * b will be moved in 2-nd pass rounds only 126 */ 127 128 129 #define roundend(a,b,c,x) \ 130 : "+r" (a), "+r" (b), "+r" (c) \ 131 : "0" (a), "1" (b), "2" (c), "m" (x), "r" (&tiger_table),\ 132 "i" (MASK0), "i" (MASK8), "i" (MASK16), "r" (MASK32), "r" (MASK40), "r" (MASK48) \ 133 : "3", "%rax","%rbx","%rcx","%rdx","%rsi", "%edi", "%r8" ); 134 135 136 /* c ^= x; 137 a -= t1[BN(c,0)] ^ t2[BN(c,2)] ^ 138 t3[BN(c,4)] ^ t4[BN(c,6)] ; 139 b += t4[BN(c,1)] ^ t3[BN(c,3)] ^ 140 t2[BN(c,5)] ^ t1[BN(c,7)] ; */ 141 142 #define roundX(a,b,c,x) \ 143 " movl %10, %%ebx \n"\ 144 " movq %11, %%rcx \n"\ 145 " movq %13, %%rdx \n"\ 146 " movq %6, %%r8 \n"\ 147 " xorq %%r8, %2 \n" \ 148 " andq %2, %%rbx \n"\ 149 " andq %2, %%rcx \n"\ 150 " andq %2, %%rdx \n"\ 151 " shrl $(16-3), %%ebx \n"\ 152 " shrq $(32-3), %%rcx \n"\ 153 " shrq $(48-3), %%rdx \n"\ 154 " movzbl %2b, %%eax \n"\ 155 " movzwl %2w, %%edi \n"\ 156 " movq (%7,%%rax,8), %%rsi \n"\ 157 " shrl $(8), %%edi \n" \ 158 " movq %2, %%rax \n" \ 159 " xorq (2048*1)(%7,%%rbx), %%rsi \n"\ 160 " movq %2, %%rbx \n"\ 161 " shrl $24, %%eax \n"\ 162 " andq %12, %%rbx \n"\ 163 " xorq (2048*2)(%7,%%rcx), %%rsi \n"\ 164 " shrq $(40-3), %%rbx \n"\ 165 " movq %2, %%rcx \n"\ 166 " xorq (2048*3)(%7,%%rdx), %%rsi \n"\ 167 " movq (2048*3)(%7,%%rdi,8), %%rdx \n"\ 168 " shrq $56, %%rcx \n"\ 169 " xorq (2048*2)(%7,%%rax,8), %%rdx \n"\ 170 " xorq (2048*1)(%7,%%rbx), %%rdx \n" \ 171 " subq %%rsi, %0 \n"\ 172 " xorq (%7,%%rcx,8), %%rdx \n"\ 173 " addq %%rdx, %1 \n" 174 175 #define round5(a,b,c,x) \ 176 roundstart \ 177 roundX(a,b,c,x) \ 178 /* b*=5; */ \ 179 "leaq (%1,%1,4), %1\n" \ 180 roundend(a,b,c,x) 181 182 183 #define round7(a,b,c,x) \ 184 roundstart \ 185 roundX(a,b,c,x) \ 186 roundend(a,b,c,x) \ 187 /* b*=7; */ \ 188 __asm__ ( \ 189 "leaq (%1,%1,8), %0\n" \ 190 "addq %1, %1 \n" \ 191 "subq %1, %0 " \ 192 :"=&r" (b): "r"(b): "1" ); 193 194 #define round9(a,b,c,x) \ 195 roundstart \ 196 roundX(a,b,c,x) \ 197 "leaq (%1,%1,8), %1\n" \ 198 roundend(a,b,c,x) 199 200 #endif 201 202 203 204 205 /* ============== Common macros ================== */ 126 206 127 207 #define key_schedule \ 128 x0 -= x7 ^ 0xA5A5A5A5A5A5A5A5LL; \ 129 x1 ^= x0; \ 130 x2 += x1; \ 131 x3 -= x2 ^ ((~x1)<<19); \ 132 x4 ^= x3; \ 133 x5 += x4; \ 134 x6 -= x5 ^ ((~x4)>>23); \ 135 x7 ^= x6; \ 136 x0 += x7; \ 137 x1 -= x0 ^ ((~x7)<<19); \ 138 x2 ^= x1; \ 139 x3 += x2; \ 140 x4 -= x3 ^ ((~x2)>>23); \ 141 x5 ^= x4; \ 142 x6 += x5; \ 143 x7 -= x6 ^ 0x0123456789ABCDEFLL; 208 x0 -= x7 ^ XOR_CONST1; \ 209 x1 ^= x0; \ 210 x2 += x1;\ 211 x3 -= x2 ^ ((~x1)<<19);\ 212 x4 ^= x3;\ 213 x5 += x4;\ 214 x6 -= x5 ^ ((~x4)>>23); \ 215 x7 ^= x6; \ 216 x0 += x7; \ 217 x1 -= x0 ^ ((~x7)<<19); \ 218 x2 ^= x1; \ 219 x3 += x2; \ 220 x4 -= x3 ^ ((~x2)>>23); \ 221 x5 ^= x4; \ 222 x6 += x5; \ 223 x7 -= x6 ^ XOR_CONST2; 224 225 #define pass5n(a,b,c) \ 226 round5(a,b,c,x0) \ 227 x0 -= x7 ^ XOR_CONST1; \ 228 round5(b,c,a,x1) \ 229 x1 ^= x0; \ 230 round5(c,a,b,x2) \ 231 x2 += x1; \ 232 round5(a,b,c,x3) \ 233 x3 -= x2 ^ ((~x1)<<19); \ 234 round5(b,c,a,x4) \ 235 x4 ^= x3; \ 236 round5(c,a,b,x5) \ 237 x5 += x4; \ 238 round5(a,b,c,x6) \ 239 x6 -= x5 ^ ((~x4)>>23); \ 240 round5(b,c,a,x7) \ 241 x7 ^= x6; \ 242 x0 += x7; \ 243 x1 -= x0 ^ ((~x7)<<19); \ 244 x2 ^= x1; \ 245 x3 += x2; \ 246 x4 -= x3 ^ ((~x2)>>23); \ 247 x5 ^= x4; \ 248 x6 += x5; \ 249 x7 -= x6 ^ XOR_CONST2; 250 251 #define pass7n(a,b,c) \ 252 round7(a,b,c,x0) \ 253 x0 -= x7 ^ XOR_CONST1; \ 254 round7(b,c,a,x1) \ 255 x1 ^= x0; \ 256 round7(c,a,b,x2) \ 257 x2 += x1; \ 258 round7(a,b,c,x3) \ 259 x3 -= x2 ^ ((~x1)<<19); \ 260 round7(b,c,a,x4) \ 261 x4 ^= x3; \ 262 round7(c,a,b,x5) \ 263 x5 += x4; \ 264 round7(a,b,c,x6) \ 265 x6 -= x5 ^ ((~x4)>>23); \ 266 round7(b,c,a,x7) \ 267 x7 ^= x6; \ 268 x0 += x7; \ 269 x1 -= x0 ^ ((~x7)<<19); \ 270 x2 ^= x1; \ 271 x3 += x2; \ 272 x4 -= x3 ^ ((~x2)>>23); \ 273 x5 ^= x4; \ 274 x6 += x5; \ 275 x7 -= x6 ^ XOR_CONST2; 276 277 #define pass5(a,b,c) \ 278 pass_start \ 279 round5(a,b,c,x0) \ 280 round5(b,c,a,x1) \ 281 round5(c,a,b,x2) \ 282 round5(a,b,c,x3) \ 283 round5(b,c,a,x4) \ 284 round5(c,a,b,x5) \ 285 round5(a,b,c,x6) \ 286 round5(b,c,a,x7) \ 287 pass_end 288 289 #define pass7(a,b,c) \ 290 pass_start \ 291 round7(a,b,c,x0) \ 292 round7(b,c,a,x1) \ 293 round7(c,a,b,x2) \ 294 round7(a,b,c,x3) \ 295 round7(b,c,a,x4) \ 296 round7(c,a,b,x5) \ 297 round7(a,b,c,x6) \ 298 round7(b,c,a,x7) \ 299 pass_end 300 301 302 #define pass9(a,b,c) \ 303 pass_start \ 304 round9(a,b,c,x0) \ 305 round9(b,c,a,x1) \ 306 round9(c,a,b,x2) \ 307 round9(a,b,c,x3) \ 308 round9(b,c,a,x4) \ 309 round9(c,a,b,x5) \ 310 round9(a,b,c,x6) \ 311 round9(b,c,a,x7) \ 312 pass_end 144 313 145 314 #define feedforward \ 146 a ^= aa; \ 147 b -= bb; \ 148 c += cc; 149 150 #ifdef OPTIMIZE_FOR_ALPHA 151 /* The loop is unrolled: works better on Alpha */ 315 a ^= aa; \ 316 b -= bb; \ 317 c += cc; 318 319 320 /* This version works ok with C variant and also with new asm version 321 * that just wastes a register r8 322 * reason? who knows, write forwarding is faster than keeping value 323 * in register? :) 324 */ 152 325 #define compress \ 153 save_abc \ 154 pass(a,b,c,5) \ 155 key_schedule \ 156 pass(c,a,b,7) \ 157 key_schedule \ 158 pass(b,c,a,9) \ 159 for(pass_no=3; pass_no<PASSES; pass_no++) { \ 160 key_schedule \ 161 pass(a,b,c,9) \ 162 tmpa=a; a=c; c=b; b=tmpa;} \ 163 feedforward 164 #else 165 /* loop: works better on PC and Sun (smaller cache?) */ 166 #define compress \ 167 save_abc \ 168 for(pass_no=0; pass_no<PASSES; pass_no++) { \ 169 if(pass_no != 0) {key_schedule} \ 170 pass(a,b,c,(pass_no==0?5:pass_no==1?7:9)); \ 171 tmpa=a; a=c; c=b; b=tmpa;} \ 172 feedforward 173 #endif 326 save_abc \ 327 pass5n(a,b,c) \ 328 pass7n(c,a,b) \ 329 pass9(b,c,a) \ 330 for(pass_no=3; pass_no<PASSES; pass_no++) { \ 331 key_schedule \ 332 pass9(a,b,c) \ 333 tmpa=a; a=c; c=b; b=tmpa; \ 334 } \ 335 feedforward 336 337 #define compress_old \ 338 save_abc \ 339 pass5(a,b,c) \ 340 key_schedule \ 341 pass7(c,a,b) \ 342 key_schedule \ 343 pass9(b,c,a) \ 344 for(pass_no=3; pass_no<PASSES; pass_no++) { \ 345 key_schedule \ 346 pass9(a,b,c) \ 347 tmpa=a; a=c; c=b; b=tmpa; \ 348 } \ 349 feedforward 174 350 175 351 #define tiger_compress_macro(str, state) \ 176 352 { \ 177 register word64 a, b, c, tmpa; \ 353 register word64 a, b, c; \ 354 register word64 tmpa; \ 178 355 word64 aa, bb, cc; \ 179 registerword64 x0, x1, x2, x3, x4, x5, x6, x7; \356 word64 x0, x1, x2, x3, x4, x5, x6, x7; \ 180 357 int pass_no; \ 181 358 \ … … 194 371 } 195 372 196 /* The compress function is a function. Requires smaller cache? */197 373 void tiger_compress(word64 *str, word64 state[3]) 198 374 { 199 #ifndef S_SPLINT_S200 375 tiger_compress_macro(((word64*)str), ((word64*)state)); 201 #endif202 376 } 203 204 #ifdef OPTIMIZE_FOR_ALPHA205 /* The compress function is inlined: works better on Alpha. */206 /* Still leaves the function above in the code, in case some other */207 /* module calls it directly. */208 #define tiger_compress(str, state) \209 tiger_compress_macro(((word64*)str), ((word64*)state))210 #endif211 377 212 378 void tiger_t(word64 *str, word64 length, word64 res[3]) … … 220 386 221 387 /* 222 res[0]=0x0123456789ABCDEFLL;223 res[1]=0xFEDCBA9876543210LL;224 res[2]=0xF096A5B4C3B2E187LL;225 */388 * res[0]=0x0123456789ABCDEFLL; 389 * res[1]=0xFEDCBA9876543210LL; 390 * res[2]=0xF096A5B4C3B2E187LL; 391 */ 226 392 227 393 for(i=length; i>=64; i-=64) … … 229 395 #ifdef BIG_ENDIAN 230 396 for(j=0; j<64; j++) 231 397 temp[j^7] = ((sh_byte*)str)[j]; 232 398 tiger_compress(((word64*)temp), res); 233 399 #else … … 236 402 str += 8; 237 403 } 238 239 404 } 240 405 … … 246 411 247 412 /* 248 res[0]=0x0123456789ABCDEFLL;249 res[1]=0xFEDCBA9876543210LL;250 res[2]=0xF096A5B4C3B2E187LL;251 */413 * res[0]=0x0123456789ABCDEFLL; 414 * res[1]=0xFEDCBA9876543210LL; 415 * res[2]=0xF096A5B4C3B2E187LL; 416 */ 252 417 253 418 for(i=length; i>=64; i-=64) … … 255 420 #ifdef BIG_ENDIAN 256 421 for(j=0; j<64; j++) 257 422 temp[j^7] = ((sh_byte*)str)[j]; 258 423 tiger_compress(((word64*)temp), res); 259 424 #else … … 272 437 temp[j^7] = 0; 273 438 #else 439 440 #ifndef USE_MEMSET 274 441 for(j=0; j<i; j++) 275 442 temp[j] = ((sh_byte*)str)[j]; 276 443 #else 444 memcpy( temp, str, j=i ); 445 #endif 277 446 temp[j++] = 0x01; 278 447 for(; j&7; j++) 279 temp[j] = 0; 280 #endif 448 temp[j] = 0; 449 450 #endif 451 281 452 if(j>56) 282 453 { 454 #ifndef USE_MEMSET 283 455 for(; j<64; j++) 284 456 temp[j] = 0; 457 #else 458 memset( temp+j, 0, 64-j); 459 #endif 285 460 tiger_compress(((word64*)temp), res); 286 461 j=0; 287 462 } 288 463 464 #ifndef USE_MEMSET 289 465 for(; j<56; j++) 290 466 temp[j] = 0; 467 #else 468 memset( temp+j, 0, 56-j); 469 #endif 470 291 471 ((word64*)(&(temp[56])))[0] = ((word64)length)<<3; 292 472 tiger_compress(((word64*)temp), res); 293 473 } 294 474 295 #else 296 297 void dummy_1_64 (int a) 298 { 299 (void) a; 300 return; 301 } 302 303 #endif 304 305 306 307 308 309 310 311 312 475 #endif -
trunk/src/sh_tiger2.c
r1 r18 23 23 24 24 25 #if !defined(HAVE_LONG_64) && !defined(HAVE_LONG_LONG_64) 26 25 #if !defined(TIGER_64_BIT) 26 27 /* #if !defined(HAVE_LONG_64) && !defined(HAVE_LONG_LONG_64) */ 27 28 28 29 /* sboxes32.c: Tiger S boxes for 32-bit-only compilers */ 29 typedef unsigned long word32; 30 word32 tiger_table[4*256][2] = { 30 #if defined(HAVE_INT_32) 31 typedef unsigned int sh_word32; 32 #elif defined(HAVE_LONG_32) 33 typedef unsigned long sh_word32; 34 #elif defined(HAVE_SHORT_32) 35 typedef unsigned short sh_word32; 36 #else 37 #error No 32 bit type found ! 38 #endif 39 40 sh_word32 tiger_table[4*256][2] = { 31 41 { 0xF7E90C5E, 0x02AAB17C /* 0 */}, { 0xE243A8EC, 0xAC424B03 /* 1 */}, 32 42 { 0x0DD5FCD3, 0x72CD5BE3 /* 2 */}, { 0xF6F97F3A, 0x6D019B93 /* 3 */}, -
trunk/src/sh_tiger2_64.c
r1 r18 22 22 #include "config_xor.h" 23 23 24 25 #if defined(HAVE_LONG_64) || defined(HAVE_LONG_LONG_64) 24 #if defined(TIGER_64_BIT) 25 26 /* #if defined(HAVE_LONG_64) || defined(HAVE_LONG_LONG_64) */ 26 27 27 28 /*@-type@*/ … … 30 31 #if defined(HAVE_LONG_64) 31 32 typedef unsigned long int word64; 33 #elif defined(HAVE_LONG_LONG_64) 34 typedef unsigned long long int word64; 32 35 #else 33 typedef unsigned long long int word64; 36 #error No 64 bit type found ! 34 37 #endif 35 38 -
trunk/src/sh_tools.c
r12 r18 125 125 char * sh_tools_safe_name (const char * instr, int flag) 126 126 { 127 unsigned char c ;127 unsigned char c, d; 128 128 const char * p; 129 129 char *q; … … 133 133 int i = 0; 134 134 unsigned char val_octal = '\0'; 135 static char ctable[16] = { '0', '1', '2', '3', '4', '5', '6', '7', 136 '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; 135 137 136 138 SL_ENTER(_("sh_tools_safe_name")); … … 202 204 { 203 205 --i; 204 sprintf(&outstr[i], "=%02x", c); /* known to fit */ 206 d = c % 16; c = c / 16; 207 outstr[i] = '='; ++i; 208 outstr[i] = ctable[c]; ++i; 209 outstr[i] = ctable[d]; ++i; 205 210 } 206 211 … … 274 279 break; 275 280 default: 276 if (strlen(p) < 3) 281 if (strlen(p) < 3) /* certainly not an octal number, skip */ 277 282 { 278 283 p += strlen(p); … … 284 289 if (val_octal != '\0') { 285 290 c = val_octal; 286 sprintf(&outstr[i], "=%02x", c); /* known to fit */ 287 i+=3; 291 d = c % 16; c = c / 16; 292 outstr[i] = '='; ++i; 293 outstr[i] = ctable[c]; ++i; 294 outstr[i] = ctable[d]; ++i; 288 295 } 289 296 p += 3; … … 294 301 { 295 302 ++p; 296 if (!p || !(*p)) 297 break; 303 if (!p || !(*p)) 304 { 305 outstr[i] = '&'; ++i; 306 break; 307 } 298 308 299 309 if (p[0] == 'a' && p[1] == 'm' && p[2] == 'p' && p[3] == ';') -
trunk/src/sh_unix.c
r10 r18 1283 1283 */ 1284 1284 if (0 == sl_strncmp((*env), _("MYSQL_UNIX_PORT="), 16)) 1285 { 1286 ++(env); 1287 continue; 1288 } 1289 if (0 == sl_strncmp((*env), _("MYSQL_TCP_PORT="), 15)) 1290 { 1291 ++(env); 1292 continue; 1293 } 1294 if (0 == sl_strncmp((*env), _("MYSQL_HOME="), 11)) 1285 1295 { 1286 1296 ++(env);
Note:
See TracChangeset
for help on using the changeset viewer.