- Timestamp:
- Jan 5, 2006, 11:15:45 PM (19 years ago)
- Location:
- trunk/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_database.c
r11 r12 53 53 int val; 54 54 int size; 55 int alen; 55 56 size_t off; 56 57 } my_attr; … … 124 125 } dbins; 125 126 127 static my_attr * attr_tab_srch = NULL; 128 static int attr_tab_srch_siz = 0; 129 126 130 static my_attr attr_tab[] = { 127 { NULL, N_("sev"), 0, 1, 8, offsetof(struct dbins_, sev) },128 { NULL, N_("tstamp"), 0, 2, 16, offsetof(struct dbins_, time) },129 { NULL, N_("remote_host"), 0, 3, 64, offsetof(struct dbins_, host) },130 { NULL, N_("msg"), 0, 4, 1024, offsetof(struct dbins_, msg) },131 132 { NULL, N_("path"), 0, 5,12288, offsetof(struct dbins_, path) },131 { NULL, N_("sev"), 0, 1, 8, 0, offsetof(struct dbins_, sev) }, 132 { NULL, N_("tstamp"), 0, 2, 16, 0, offsetof(struct dbins_, time) }, 133 { NULL, N_("remote_host"), 0, 3, 64, 0, offsetof(struct dbins_, host) }, 134 { NULL, N_("msg"), 0, 4, 1024, 0, offsetof(struct dbins_, msg) }, 135 136 { NULL, N_("path"), 0, 5,12288, 0, offsetof(struct dbins_, path) }, 133 137 /* username -> userid; replace (long) 'userid' - below - by 'dummy' */ 134 { NULL, N_("userid"), 0, 6, 9, offsetof(struct dbins_, user) },135 { NULL, N_("group"), 0, 7, 9, offsetof(struct dbins_, group) },136 { NULL, N_("program"), 0, 8, 8, offsetof(struct dbins_, program) },137 { NULL, N_("subroutine"), 0, 9, 16, offsetof(struct dbins_, subroutine)},138 { NULL, N_("status"), 0, 10, 12, offsetof(struct dbins_, status) },139 { NULL, N_("hash"), 0, 11, 50, offsetof(struct dbins_, hash) },140 { NULL, N_("path_data"), 0, 12, 1024, offsetof(struct dbins_, path_data) },141 { NULL, N_("hash_data"), 0, 13, 50, offsetof(struct dbins_, hash_data) },142 { NULL, N_("key_uid"), 0, 14, 64, offsetof(struct dbins_, key_uid) },143 { NULL, N_("key_uid_data"),0, 15, 64, offsetof(struct dbins_, key_uid_data)},144 { NULL, N_("key_id"), 0, 16, 16, offsetof(struct dbins_, key_id) },145 { NULL, N_("module"), 0, 17, 8, offsetof(struct dbins_, module) },146 { NULL, N_("syscall"), 0, 19, 16, offsetof(struct dbins_, syscall) },147 { NULL, N_("ip"), 0, 20, 16, offsetof(struct dbins_, ip) },148 { NULL, N_("tty"), 0, 21, 16, offsetof(struct dbins_, tty) },149 { NULL, N_("peer"), 0, 22, 64, offsetof(struct dbins_, peer) },150 { NULL, N_("obj"), 0, 23, 1024, offsetof(struct dbins_, obj) },151 { NULL, N_("interface"), 0, 24, 64, offsetof(struct dbins_, interface)},152 { NULL, N_("time"), 0, 25, 64, offsetof(struct dbins_, ltime) },153 { NULL, N_("dir"), 0, 26, 1024, offsetof(struct dbins_, dir) },154 { NULL, N_("linked_path"), 0, 27, 1024, offsetof(struct dbins_, linked_path)},155 { NULL, N_("service"), 0, 29, 64, offsetof(struct dbins_, service)},156 { NULL, N_("facility"), 0, 30, 32, offsetof(struct dbins_, facility) },157 { NULL, N_("priority"), 0, 31, 32, offsetof(struct dbins_, priority) },158 { NULL, N_("syslog_msg"), 0, 32, 1024, offsetof(struct dbins_, syslog_msg) },159 160 { NULL, N_("mode_old"), 0, 33, 16, offsetof(struct dbins_, mode_old) },161 { NULL, N_("mode_new"), 0, 34, 16, offsetof(struct dbins_, mode_new) },162 { NULL, N_("device_old"), 0, 35, 16, offsetof(struct dbins_, device_old)},163 { NULL, N_("device_new"), 0, 36, 16, offsetof(struct dbins_, device_new)},164 { NULL, N_("owner_old"), 0, 37, 9, offsetof(struct dbins_, owner_old)},165 { NULL, N_("owner_new"), 0, 38, 9, offsetof(struct dbins_, owner_new)},166 { NULL, N_("group_old"), 0, 39, 9, offsetof(struct dbins_, group_old)},167 { NULL, N_("group_new"), 0, 40, 9, offsetof(struct dbins_, group_new)},168 { NULL, N_("ctime_old"), 0, 41, 20, offsetof(struct dbins_, ctime_old)},169 { NULL, N_("ctime_new"), 0, 42, 20, offsetof(struct dbins_, ctime_new)},170 { NULL, N_("atime_old"), 0, 43, 20, offsetof(struct dbins_, atime_old)},171 { NULL, N_("atime_new"), 0, 44, 20, offsetof(struct dbins_, atime_new)},172 { NULL, N_("mtime_old"), 0, 45, 20, offsetof(struct dbins_, mtime_old)},173 { NULL, N_("mtime_new"), 0, 46, 20, offsetof(struct dbins_, mtime_new)},174 { NULL, N_("chksum_old"), 0, 47, 50, offsetof(struct dbins_, chksum_old)},175 { NULL, N_("chksum_new"), 0, 48, 50, offsetof(struct dbins_, chksum_new)},176 { NULL, N_("link_old"), 0, 49, 1024, offsetof(struct dbins_, link_old)},177 { NULL, N_("link_new"), 0, 50, 1024, offsetof(struct dbins_, link_new)},178 179 { NULL, N_("size_old"), 0, 51, 0, 0 },180 { NULL, N_("size_new"), 0, 52, 0, 0 },181 { NULL, N_("hardlinks_old"),0, 53, 0, 0 },182 { NULL, N_("hardlinks_new"),0, 54, 0, 0 },183 { NULL, N_("inode_old"), 0, 55, 0, 0 },184 { NULL, N_("inode_new"), 0, 56, 0, 0 },185 186 { NULL, N_("imode_old"), 0, 57, 0, 0 },187 { NULL, N_("imode_new"), 0, 58, 0, 0 },188 { NULL, N_("iattr_old"), 0, 59, 0, 0 },189 { NULL, N_("iattr_new"), 0, 60, 0, 0 },190 { NULL, N_("idevice_old"), 0, 61, 0, 0 },191 { NULL, N_("idevice_new"), 0, 62, 0, 0 },192 { NULL, N_("iowner_old"), 0, 63, 0, 0 },193 { NULL, N_("iowner_new"), 0, 64, 0, 0 },194 { NULL, N_("igroup_old"), 0, 65, 0, 0 },195 { NULL, N_("igroup_new"), 0, 66, 0, 0 },196 197 { NULL, N_("port"), 0, 67, 0, 0 },198 { NULL, N_("return_code"), 0, 68, 0, 0 },138 { NULL, N_("userid"), 0, 6, 9, 0, offsetof(struct dbins_, user) }, 139 { NULL, N_("group"), 0, 7, 9, 0, offsetof(struct dbins_, group) }, 140 { NULL, N_("program"), 0, 8, 8, 0, offsetof(struct dbins_, program) }, 141 { NULL, N_("subroutine"), 0, 9, 16, 0, offsetof(struct dbins_, subroutine)}, 142 { NULL, N_("status"), 0, 10, 12, 0, offsetof(struct dbins_, status) }, 143 { NULL, N_("hash"), 0, 11, 50, 0, offsetof(struct dbins_, hash) }, 144 { NULL, N_("path_data"), 0, 12, 1024, 0, offsetof(struct dbins_, path_data) }, 145 { NULL, N_("hash_data"), 0, 13, 50, 0, offsetof(struct dbins_, hash_data) }, 146 { NULL, N_("key_uid"), 0, 14, 64, 0, offsetof(struct dbins_, key_uid) }, 147 { NULL, N_("key_uid_data"),0, 15, 64, 0, offsetof(struct dbins_, key_uid_data)}, 148 { NULL, N_("key_id"), 0, 16, 16, 0, offsetof(struct dbins_, key_id) }, 149 { NULL, N_("module"), 0, 17, 8, 0, offsetof(struct dbins_, module) }, 150 { NULL, N_("syscall"), 0, 19, 16, 0, offsetof(struct dbins_, syscall) }, 151 { NULL, N_("ip"), 0, 20, 16, 0, offsetof(struct dbins_, ip) }, 152 { NULL, N_("tty"), 0, 21, 16, 0, offsetof(struct dbins_, tty) }, 153 { NULL, N_("peer"), 0, 22, 64, 0, offsetof(struct dbins_, peer) }, 154 { NULL, N_("obj"), 0, 23, 1024, 0, offsetof(struct dbins_, obj) }, 155 { NULL, N_("interface"), 0, 24, 64, 0, offsetof(struct dbins_, interface)}, 156 { NULL, N_("time"), 0, 25, 64, 0, offsetof(struct dbins_, ltime) }, 157 { NULL, N_("dir"), 0, 26, 1024, 0, offsetof(struct dbins_, dir) }, 158 { NULL, N_("linked_path"), 0, 27, 1024, 0, offsetof(struct dbins_, linked_path)}, 159 { NULL, N_("service"), 0, 29, 64, 0, offsetof(struct dbins_, service)}, 160 { NULL, N_("facility"), 0, 30, 32, 0, offsetof(struct dbins_, facility) }, 161 { NULL, N_("priority"), 0, 31, 32, 0, offsetof(struct dbins_, priority) }, 162 { NULL, N_("syslog_msg"), 0, 32, 1024, 0, offsetof(struct dbins_, syslog_msg) }, 163 164 { NULL, N_("mode_old"), 0, 33, 16, 0, offsetof(struct dbins_, mode_old) }, 165 { NULL, N_("mode_new"), 0, 34, 16, 0, offsetof(struct dbins_, mode_new) }, 166 { NULL, N_("device_old"), 0, 35, 16, 0, offsetof(struct dbins_, device_old)}, 167 { NULL, N_("device_new"), 0, 36, 16, 0, offsetof(struct dbins_, device_new)}, 168 { NULL, N_("owner_old"), 0, 37, 9, 0, offsetof(struct dbins_, owner_old)}, 169 { NULL, N_("owner_new"), 0, 38, 9, 0, offsetof(struct dbins_, owner_new)}, 170 { NULL, N_("group_old"), 0, 39, 9, 0, offsetof(struct dbins_, group_old)}, 171 { NULL, N_("group_new"), 0, 40, 9, 0, offsetof(struct dbins_, group_new)}, 172 { NULL, N_("ctime_old"), 0, 41, 20, 0, offsetof(struct dbins_, ctime_old)}, 173 { NULL, N_("ctime_new"), 0, 42, 20, 0, offsetof(struct dbins_, ctime_new)}, 174 { NULL, N_("atime_old"), 0, 43, 20, 0, offsetof(struct dbins_, atime_old)}, 175 { NULL, N_("atime_new"), 0, 44, 20, 0, offsetof(struct dbins_, atime_new)}, 176 { NULL, N_("mtime_old"), 0, 45, 20, 0, offsetof(struct dbins_, mtime_old)}, 177 { NULL, N_("mtime_new"), 0, 46, 20, 0, offsetof(struct dbins_, mtime_new)}, 178 { NULL, N_("chksum_old"), 0, 47, 50, 0, offsetof(struct dbins_, chksum_old)}, 179 { NULL, N_("chksum_new"), 0, 48, 50, 0, offsetof(struct dbins_, chksum_new)}, 180 { NULL, N_("link_old"), 0, 49, 1024, 0, offsetof(struct dbins_, link_old)}, 181 { NULL, N_("link_new"), 0, 50, 1024, 0, offsetof(struct dbins_, link_new)}, 182 183 { NULL, N_("size_old"), 0, 51, 0, 0, 0 }, 184 { NULL, N_("size_new"), 0, 52, 0, 0, 0 }, 185 { NULL, N_("hardlinks_old"),0, 53, 0, 0, 0 }, 186 { NULL, N_("hardlinks_new"),0, 54, 0, 0, 0 }, 187 { NULL, N_("inode_old"), 0, 55, 0, 0, 0 }, 188 { NULL, N_("inode_new"), 0, 56, 0, 0, 0 }, 189 190 { NULL, N_("imode_old"), 0, 57, 0, 0, 0 }, 191 { NULL, N_("imode_new"), 0, 58, 0, 0, 0 }, 192 { NULL, N_("iattr_old"), 0, 59, 0, 0, 0 }, 193 { NULL, N_("iattr_new"), 0, 60, 0, 0, 0 }, 194 { NULL, N_("idevice_old"), 0, 61, 0, 0, 0 }, 195 { NULL, N_("idevice_new"), 0, 62, 0, 0, 0 }, 196 { NULL, N_("iowner_old"), 0, 63, 0, 0, 0 }, 197 { NULL, N_("iowner_new"), 0, 64, 0, 0, 0 }, 198 { NULL, N_("igroup_old"), 0, 65, 0, 0, 0 }, 199 { NULL, N_("igroup_new"), 0, 66, 0, 0, 0 }, 200 201 { NULL, N_("port"), 0, 67, 0, 0, 0 }, 202 { NULL, N_("return_code"), 0, 68, 0, 0, 0 }, 199 203 /* { NULL, N_("userid"), 0, 69, 0, 0 }, old 'userid', 1.8.1 */ 200 204 201 { NULL, N_("host"), 0, 70, 64, offsetof(struct dbins_, fromhost)},202 { NULL, N_("attr_old"), 0, 71, 16, offsetof(struct dbins_, attr_old)},203 { NULL, N_("attr_new"), 0, 72, 16, offsetof(struct dbins_, attr_new)},204 205 { NULL, NULL, 0, 0, 0, 0 }205 { NULL, N_("host"), 0, 70, 64, 0, offsetof(struct dbins_, fromhost)}, 206 { NULL, N_("attr_old"), 0, 71, 16, 0, offsetof(struct dbins_, attr_old)}, 207 { NULL, N_("attr_new"), 0, 72, 16, 0, offsetof(struct dbins_, attr_new)}, 208 209 { NULL, NULL, 0, 0, 0, 0, 0 } 206 210 }; 207 211 … … 1179 1183 } 1180 1184 } 1185 #if 0 1186 /* apparently slower, see gyule.7 */ 1187 len = (long) strlen(val); 1188 1189 if ((val[0] != '\0') && (*size > 2)) 1190 { 1191 if (flag == 1) 1192 { 1193 *end = ','; ++end; 1194 *end = '\''; ++end; (*size) -= 2; 1195 *end = '\0'; 1196 1197 if ((long) *size > (len+2)) 1198 { 1199 (void) sl_strlcat(end, val, (size_t) *size); 1200 end += len; (*size) -= len; 1201 *end = '\''; ++end; (*size) -= 1; 1202 } 1203 *end = '\0'; 1204 } 1205 else 1206 { 1207 *end = ','; ++end; (*size) -= 1; 1208 *end = '\0'; 1209 1210 if ((long) *size > (len+1)) 1211 { 1212 (void) sl_strlcat(end, val, (size_t) *size); 1213 end += len; (*size) -= len; 1214 } 1215 *end = '\0'; 1216 } 1217 } 1218 #endif 1181 1219 return end; 1182 1220 } … … 1375 1413 } 1376 1414 1415 static int sh_database_comp_attr (const void *m1, const void *m2) 1416 { 1417 my_attr *mi1 = (my_attr *) m1; 1418 my_attr *mi2 = (my_attr *) m2; 1419 return strcmp(mi1->attr, mi2->attr); 1420 } 1421 1377 1422 1378 1423 static void init_attr_table() 1379 1424 { 1380 1425 static int first = S_TRUE; 1381 int i ;1426 int i, j; 1382 1427 1383 1428 #ifdef SH_STEALTH 1384 1429 int j, k; 1385 1430 1386 if (first == S_TRUE) 1387 { 1388 i = 0; 1389 while (attr_tab[i].attr_o != NULL) 1390 { 1391 j = strlen(attr_tab[i].attr_o); 1392 attr_tab[i].attr = malloc (j+1); /* only once */ 1393 if (NULL == attr_tab[i].attr) 1394 SL_RETURN (NULL, _("sh_database_parse")); 1395 for (k = 0; k < j; ++k) 1396 attr_tab[i].attr[k] = attr_tab[i].attr_o[k] ^ XOR_CODE; 1397 attr_tab[i].attr[j] = '\0'; 1398 ++i; 1399 } 1400 first = S_FALSE; 1401 } 1431 if (first == S_FALSE) 1432 return; 1433 1434 i = 0; 1435 while (attr_tab[i].attr_o != NULL) 1436 { 1437 j = strlen(attr_tab[i].attr_o); 1438 attr_tab[i].attr = malloc (j+1); /* only once */ 1439 if (NULL == attr_tab[i].attr) 1440 SL_RETURN (NULL, _("sh_database_parse")); 1441 for (k = 0; k < j; ++k) 1442 attr_tab[i].attr[k] = attr_tab[i].attr_o[k] ^ XOR_CODE; 1443 attr_tab[i].attr[j] = '\0'; 1444 attr_tab[i].alen = strlen(attr_tab[i].attr_o); 1445 ++i; 1446 } 1447 first = S_FALSE; 1448 1402 1449 #else 1403 if (first == S_TRUE) 1404 {1405 i = 0;1406 while (attr_tab[i].attr_o != NULL)1407 { 1408 attr_tab[i].attr = attr_tab[i].attr_o;1409 1410 1411 1412 } 1450 1451 i = 0; 1452 while (attr_tab[i].attr_o != NULL) 1453 { 1454 attr_tab[i].attr = attr_tab[i].attr_o; 1455 attr_tab[i].alen = strlen(attr_tab[i].attr_o); 1456 ++i; 1457 } 1458 first = S_FALSE; 1459 1413 1460 #endif 1461 1462 /* create a sorted table for binary search 1463 */ 1464 attr_tab_srch = SH_ALLOC(i * sizeof(my_attr)); 1465 for (j=0; j<i; ++j) 1466 memcpy(&attr_tab_srch[j], &attr_tab[j], sizeof(my_attr)); 1467 qsort(attr_tab_srch, i, sizeof(my_attr), sh_database_comp_attr); 1468 attr_tab_srch_siz = i; 1469 1414 1470 return; 1415 1471 } … … 1479 1535 int i; 1480 1536 size_t j; 1537 my_attr * res; 1538 my_attr key; 1539 char key_str[64]; 1481 1540 1482 1541 SL_ENTER(_("sh_database_parse")); … … 1497 1556 while ((p != NULL) && (*p != '\0') && (*p != '>')) 1498 1557 { 1499 if (p[0] == '/' && p[1] == '>') 1558 if (p[0] == 'l' && p[1] == 'o' && p[2] == 'g' && 1559 (p[3] == ' ' || p[3] == '>')) 1560 { 1561 p = &p[4]; 1562 goto parse; 1563 } 1564 else if (p[0] == '/' && p[1] == '>') 1500 1565 SL_RETURN (&p[2], _("sh_database_parse")); 1501 if (p[0] == '/' && p[1] == 'l' && p[2] == 'o' &&1566 else if (p[0] == '/' && p[1] == 'l' && p[2] == 'o' && 1502 1567 p[3] == 'g' && p[4] == '>') 1503 1568 SL_RETURN (&p[5], _("sh_database_parse")); 1504 if (p[0] == 'l' && p[1] == 'o' && p[2] == 'g' &&1505 (p[3] == ' ' || p[3] == '>'))1506 {1507 p = &p[4];1508 goto parse;1509 }1510 1569 ++p; 1511 1570 } … … 1519 1578 if (!p || *p == '\0') 1520 1579 SL_RETURN(NULL, _("sh_database_parse")); 1580 1581 if (*p != '<' && *p != '/') 1582 goto par2; 1521 1583 1522 1584 if (p[0] == '<' && p[1] == 'l' && … … 1536 1598 SL_RETURN (&p[5], _("sh_database_parse")); 1537 1599 1600 par2: 1538 1601 1539 1602 /* non-whitespace 1540 1603 */ 1541 1604 i = 0; 1542 while (attr_tab[i].attr != NULL) 1543 { 1544 j = strlen(attr_tab[i].attr); 1545 if (0 == strncmp(p, attr_tab[i].attr, j) && 1546 p[j] == '=' && p[j+1] == '"') 1605 for (i=0; i < 64; ++i) 1606 { 1607 key_str[i] = p[i]; 1608 if (p[i] == '=') 1609 { 1610 key_str[i] = '\0'; 1611 break; 1612 } 1613 } 1614 key_str[63] = '\0'; 1615 key.attr = &key_str[0]; 1616 1617 res = bsearch(&key, attr_tab_srch, attr_tab_srch_siz, 1618 sizeof(my_attr), sh_database_comp_attr); 1619 1620 if (res != NULL) 1621 { 1622 j = res->alen; /* strlen(attr_tab[i].attr); */ 1623 if (p[j] == '=' && p[j+1] == '"') 1547 1624 { 1548 1625 q = strchr(&p[j+2], '"'); … … 1562 1639 } 1563 1640 1564 if ( attr_tab[i].val == 1)1641 if (res->val == 1) 1565 1642 (void) sl_strlcpy(db_entry->sev, &p[j+2], 1566 (size_t) attr_tab[i].size);1567 else if ( attr_tab[i].val == 2)1643 (size_t)res->size); 1644 else if (res->val == 2) 1568 1645 { 1569 1646 z = strchr(&p[j+2], 'T'); … … 1571 1648 (void) sl_strlcpy(db_entry->time, &p[j+2], 20); 1572 1649 } 1573 else if ( attr_tab[i].val == 3)1650 else if (res->val == 3) 1574 1651 (void) sl_strlcpy(db_entry->host, &p[j+2], 1575 (size_t) attr_tab[i].size);1576 else if ( attr_tab[i].val == 4)1652 (size_t) res->size); 1653 else if (res->val == 4) 1577 1654 (void) sl_strlcpy(db_entry->msg, &p[j+2], 1578 (size_t) attr_tab[i].size);1579 else if ( attr_tab[i].size != 0)1655 (size_t) res->size); 1656 else if (res->size != 0) 1580 1657 { 1581 (void) sl_strlcpy( (((char *)(db_entry))+ attr_tab[i].off),1658 (void) sl_strlcpy( (((char *)(db_entry))+ res->off), 1582 1659 &p[j+2], 1583 (size_t) attr_tab[i].size);1660 (size_t) res->size); 1584 1661 } 1585 else if ( attr_tab[i].val >= START_SEC_LONGS)1662 else if (res->val >= START_SEC_LONGS) 1586 1663 { 1587 db_entry->long_data[ attr_tab[i].val-START_SEC_LONGS]1664 db_entry->long_data[res->val-START_SEC_LONGS] 1588 1665 = atol(&p[j+2]); 1589 1666 } -
trunk/src/sh_forward.c
r11 r12 177 177 178 178 int clt_class = (-1); 179 180 extern int flag_err_debug; 181 extern int flag_err_info; 179 182 180 183 #ifndef SH_STANDALONE … … 1225 1228 else 1226 1229 { 1227 sh_error_handle((-1), FIL__, __LINE__, 0, MSG_TCP_AUTH); 1230 if (flag_err_info == SL_TRUE) 1231 sh_error_handle((-1), FIL__, __LINE__, 0, MSG_TCP_AUTH); 1228 1232 } 1229 1233 } … … 1450 1454 /* --- SERVER CMD END --- */ 1451 1455 #endif 1452 sh_error_handle((-1), FIL__, __LINE__, 0, 1453 MSG_TCP_CONF); 1456 if (flag_err_debug == SL_TRUE) 1457 sh_error_handle((-1), FIL__, __LINE__, 0, 1458 MSG_TCP_CONF); 1454 1459 } 1455 1460 } … … 1648 1653 (void) rewind_tmp (sfd); 1649 1654 (void) sl_sync(sfd); 1650 sh_error_handle((-1), FIL__, __LINE__, 0, MSG_TCP_FOK); 1655 if (flag_err_info == SL_TRUE) 1656 sh_error_handle((-1), FIL__, __LINE__, 0, MSG_TCP_FOK); 1651 1657 } 1652 1658 else … … 2812 2818 conn->head[5] = 'L'; 2813 2819 conn->head[6] = 'T'; 2814 sh_error_handle((-1), FIL__, __LINE__, 0, MSG_TCP_FAUTH, 2815 &(conn->buf[KEY_LEN])); 2820 if (flag_err_info == SL_TRUE) 2821 sh_error_handle((-1), FIL__, __LINE__, 0, MSG_TCP_FAUTH, 2822 &(conn->buf[KEY_LEN])); 2816 2823 strcpy(conn->buf, /* known to fit */ 2817 2824 &(conn->buf[KEY_LEN])); … … 3172 3179 _("msg=<File transfer - EOTE (7).>\n"))); 3173 3180 3174 sh_error_handle((-1), FIL__, __LINE__, 0, MSG_TCP_OKFILE, 3175 conn->peer); 3181 if (flag_err_info == SL_TRUE) 3182 sh_error_handle((-1), FIL__, __LINE__, 0, MSG_TCP_OKFILE, 3183 conn->peer); 3176 3184 3177 3185 if ((conn->client_entry->status_now != CLT_SUSPEND) && … … 3267 3275 conn->head[5] = 'L'; 3268 3276 conn->head[6] = 'T'; 3269 sh_error_handle((-1), FIL__, __LINE__, 0, MSG_TCP_FAUTH, 3270 &(conn->buf[KEY_LEN])); 3277 if (flag_err_info == SL_TRUE) 3278 sh_error_handle((-1), FIL__, __LINE__, 0, MSG_TCP_FAUTH, 3279 &(conn->buf[KEY_LEN])); 3271 3280 strcpy(conn->buf, /* known to fit */ 3272 3281 &(conn->buf[KEY_LEN])); … … 3591 3600 if (0 != (conn->head[0] & SH_PROTO_END)) 3592 3601 { 3593 sh_error_handle((-1), FIL__, __LINE__, 0, MSG_TCP_OKMSG, 3594 sh_strip_domain (conn->peer)); 3602 if (flag_err_debug == SL_TRUE) 3603 sh_error_handle((-1), FIL__, __LINE__, 0, MSG_TCP_OKMSG, 3604 sh_strip_domain (conn->peer)); 3595 3605 sh_forward_do_free (conn); 3596 3606 SL_RET0(_("check_protocol")); … … 4568 4578 newconn->timer = (unsigned long) time (NULL); 4569 4579 4570 sh_error_handle((-1), FIL__, __LINE__, 0, MSG_TCP_CNEW, newconn->fd); 4580 if (flag_err_info == SL_TRUE) 4581 sh_error_handle((-1), FIL__, __LINE__, 0, MSG_TCP_CNEW, newconn->fd); 4571 4582 4572 4583 SL_RETURN( (0), _("sh_forward_accept")); -
trunk/src/sh_tools.c
r11 r12 121 121 * remaining unprintable chars --- 122 122 */ 123 #define SH_PUT_4(p, a, b, c) (p)[0] = (a); (p)[1] = (b); (p)[2] = (c); 124 123 125 char * sh_tools_safe_name (const char * instr, int flag) 124 126 { 125 static char ctest = ~('\\'|'&'|'='|'\'');126 127 unsigned char c; 127 128 const char * p; 129 char *q; 128 130 char tmp[4]; 129 131 char * outstr; … … 143 145 144 146 p = instr; 147 q = outstr; 145 148 146 149 #if !defined(SH_USE_XML) … … 166 169 if ((*p) == '"') 167 170 { 168 sprintf(&outstr[i], "=%02x", c);i+=3; ++p; /* known to fit */ 171 SH_PUT_4(&outstr[i], '=', '2', '2'); 172 i+=3; ++p; 169 173 continue; 170 174 } 171 175 else if ((*p) == '&') 172 176 { 173 sprintf(&outstr[i], "=%02x", c);i+=3; ++p; /* known to fit */ 177 SH_PUT_4(&outstr[i], '=', '2', '6'); 178 i+=3; ++p; 174 179 continue; 175 180 } 176 181 else if ((*p) == '<') 177 182 { /* left angle */ 178 sprintf(&outstr[i], "=%02x", c);i+=3; ++p; /* known to fit */ 183 SH_PUT_4(&outstr[i], '=', '3', 'c'); 184 i+=3; ++p; 179 185 continue; 180 186 } 181 187 else if ((*p) == '>') 182 188 { /* right angle */ 183 sprintf(&outstr[i], "=%02x", c);i+=3; ++p; /* known to fit */ 189 SH_PUT_4(&outstr[i], '=', '3', 'e'); 190 i+=3; ++p; 184 191 continue; 185 192 } … … 187 194 #endif 188 195 189 /* if ( (*p) != '\\' && (*p) != '&' && (*p) != '=' && (*p) != '\'') */ 190 if (((*p) & ctest) != 0) 196 if ( (*p) != '\\' && (*p) != '&' && (*p) != '=' && (*p) != '\'') 191 197 { 192 198 outstr[i] = *p; ++i; … … 203 209 else if ((*p) == '\'') 204 210 { 205 sprintf(&outstr[i], "=%02x", c); i+=3; ++p; /* known to fit */ 211 SH_PUT_4(&outstr[i], '=', '2', '7'); 212 i+=3; ++p; 206 213 } 207 214 else if (*p == '=') … … 209 216 if (p[1] != '"' && p[1] != '<') 210 217 { 211 sprintf(&outstr[i], "=%02x", c); i+=3; ++p;/* known to fit */ 218 SH_PUT_4(&outstr[i], '=', '3', 'd'); 219 i+=3; ++p; 212 220 } 213 221 else … … 226 234 switch (*p) { 227 235 case '\\': 228 sprintf(&outstr[i], "=%02x", c); i+=3; ++p; /* known to fit */ 236 SH_PUT_4(&outstr[i], '=', '5', 'c'); 237 i+=3; ++p; 229 238 break; 230 239 case 'n': 231 sprintf(&outstr[i], "=%02x", '\n'); /* known to fit */240 SH_PUT_4(&outstr[i], '=', '0', 'a'); 232 241 i+=3; ++p; 233 242 break; 234 243 case 'b': 235 sprintf(&outstr[i], "=%02x", '\b'); /* known to fit */244 SH_PUT_4(&outstr[i], '=', '0', '8'); 236 245 i+=3; ++p; 237 246 break; 238 247 case 'r': 239 sprintf(&outstr[i], "=%02x", '\r'); /* known to fit */248 SH_PUT_4(&outstr[i], '=', '0', 'd'); 240 249 i+=3; ++p; 241 250 break; 242 251 case 't': 243 sprintf(&outstr[i], "=%02x", '\t'); /* known to fit */252 SH_PUT_4(&outstr[i], '=', '0', '9'); 244 253 i+=3; ++p; 245 254 break; 246 255 case 'v': 247 sprintf(&outstr[i], "=%02x", '\v'); /* known to fit */256 SH_PUT_4(&outstr[i], '=', '0', 'b'); 248 257 i+=3; ++p; 249 258 break; 250 259 case 'f': 251 sprintf(&outstr[i], "=%02x", '\f'); /* known to fit */260 SH_PUT_4(&outstr[i], '=', '0', 'c'); 252 261 i+=3; ++p; 253 262 break; 254 263 case '\'': 255 sprintf(&outstr[i], "=%02x", '\''); /* known to fit */264 SH_PUT_4(&outstr[i], '=', '2', '7'); 256 265 i+=3; ++p; 257 266 break; 258 case ' \"': /* also encode quoted '"' */259 sprintf(&outstr[i], "=%02x", '\"'); /* known to fit */267 case '"': /* also encode quoted '"' */ 268 SH_PUT_4(&outstr[i], '=', '2', '2'); 260 269 i+=3; ++p; 261 270 break; 262 271 case ' ': 263 sprintf(&outstr[i], "=%02x", ' '); /* known to fit */272 SH_PUT_4(&outstr[i], '=', '2', '0'); 264 273 i+=3; ++p; 265 274 break; … … 290 299 if (p[0] == 'a' && p[1] == 'm' && p[2] == 'p' && p[3] == ';') 291 300 { 292 sprintf(&outstr[i], "=%02x", '&'); /* known to fit */301 SH_PUT_4(&outstr[i], '=', '2', '6'); 293 302 i+=3; p += 4; 294 303 } … … 296 305 p[4] == ';') 297 306 { 298 sprintf(&outstr[i], "=%02x", '"'); /* known to fit */307 SH_PUT_4(&outstr[i], '=', '2', '2'); 299 308 i+=3; p += 5; 300 309 } 301 310 else if (p[0] == 'l' && p[1] == 't' && p[2] == ';') 302 311 { 303 sprintf(&outstr[i], "=%02x", '<'); /* known to fit */312 SH_PUT_4(&outstr[i], '=', '3', 'c'); 304 313 i+=3; p += 3; 305 314 } 306 315 else if (p[0] == 'g' && p[1] == 't' && p[2] == ';') 307 316 { 308 sprintf(&outstr[i], "=%02x", '>'); /* known to fit */317 SH_PUT_4(&outstr[i], '=', '3', 'e'); 309 318 i+=3; p += 3; 310 319 } -
trunk/src/sh_utils.c
r11 r12 456 456 /* can't inline (AIX) 457 457 */ 458 int sh_util_hexchar( c har c )458 int sh_util_hexchar( const char c ) 459 459 { 460 460 /*@+charint@*/ … … 471 471 /* read a hexadecimal key, convert to binary 472 472 */ 473 int sh_util_hextobinary (char * binary, c har * hex, int bytes)473 int sh_util_hextobinary (char * binary, const char * hex, int bytes) 474 474 { 475 475 int i = 0, j, k, l = 0; -
trunk/src/slib.c
r8 r12 864 864 if (dst == NULL) 865 865 return SL_ENONE; 866 if (src == NULL || src == "")866 if (src == NULL || *src == '\0') 867 867 return SL_ENONE; 868 868
Note:
See TracChangeset
for help on using the changeset viewer.