- Timestamp:
- Apr 20, 2009, 5:59:31 PM (16 years ago)
- Location:
- trunk/src
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/CuTest.c
r158 r227 120 120 { 121 121 va_list argp; 122 char buf[ HUGE_STRING_LEN];122 char buf[2048]; 123 123 va_start(argp, format); 124 vs printf(buf, format, argp);124 vsnprintf(buf, sizeof(buf), format, argp); 125 125 va_end(argp); 126 126 CuStringAppend(str, buf); … … 174 174 static void CuFailInternal(CuTest* tc, const char* file, int line, CuString* string) 175 175 { 176 char buf[ HUGE_STRING_LEN];177 178 s printf(buf, "%s:%d: ", file, line);176 char buf[256]; 177 178 snprintf(buf, sizeof(buf), "%s:%d: ", file, line); 179 179 CuStringInsert(string, buf, 0); 180 180 -
trunk/src/sh_entropy.c
r174 r227 594 594 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 595 595 struct passwd pwd; 596 char buffer[SH_PWBUF_SIZE];596 char * buffer = SH_ALLOC(SH_PWBUF_SIZE); 597 597 struct passwd * tempres; 598 sh_getpwnam_r(DEFAULT_IDENT, &pwd, buffer, sizeof(buffer), &tempres);598 sh_getpwnam_r(DEFAULT_IDENT, &pwd, buffer, SH_PWBUF_SIZE, &tempres); 599 599 #else 600 600 struct passwd * tempres = sh_getpwnam(DEFAULT_IDENT); … … 614 614 i = -1; 615 615 } 616 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 617 SH_FREE(buffer); 618 #endif 616 619 } 617 620 -
trunk/src/sh_extern.c
r215 r227 1003 1003 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 1004 1004 struct passwd pwd; 1005 char buffer[SH_PWBUF_SIZE];1005 char * buffer = SH_ALLOC(SH_PWBUF_SIZE); 1006 1006 #endif 1007 1007 … … 1012 1012 if (user == NULL) 1013 1013 { 1014 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 1015 SH_FREE(buffer); 1016 #endif 1014 1017 SL_RETURN (-1, _("sh_ext_uid")); 1015 1018 } 1016 1019 1017 1020 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 1018 sh_getpwnam_r(user, &pwd, buffer, sizeof(buffer), &tempres);1021 sh_getpwnam_r(user, &pwd, buffer, SH_PWBUF_SIZE, &tempres); 1019 1022 #else 1020 1023 tempres = sh_getpwnam(user); … … 1025 1028 *uid = tempres->pw_uid; 1026 1029 *gid = tempres->pw_gid; 1030 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 1031 SH_FREE(buffer); 1032 #endif 1027 1033 SL_RETURN (0, _("sh_ext_uid")); 1028 1034 } 1029 1035 1036 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 1037 SH_FREE(buffer); 1038 #endif 1030 1039 SL_RETURN (-1, _("sh_ext_uid")); 1031 1040 } -
trunk/src/sh_files.c
r171 r227 1489 1489 int status; 1490 1490 int dummy = S_FALSE; 1491 dir_type 1491 dir_type * theDir; 1492 1492 ShFileType checkit; 1493 1493 static unsigned int state = 1; 1494 1494 1495 file_type 1495 file_type * theFile; 1496 1496 char * tmpname; 1497 1497 char * tmpcat; … … 1571 1571 /* ---- stat the directory ---- 1572 1572 */ 1573 sl_strlcpy (theFile.fullpath, iname, PATH_MAX); 1574 theFile.attr_string = NULL; 1575 theFile.link_path = NULL; 1573 theFile = SH_ALLOC(sizeof(file_type)); 1574 sl_strlcpy (theFile->fullpath, iname, PATH_MAX); 1575 theFile->attr_string = NULL; 1576 theFile->link_path = NULL; 1576 1577 1577 1578 (void) relativeName; 1578 1579 status = sh_unix_getinfo (ShDFLevel[SH_ERR_T_DIR], 1579 1580 iname, 1580 &theFile, NULL, iclass);1581 theFile, NULL, iclass); 1581 1582 1582 1583 if ((sig_termfast == 1) || (sig_terminate == 1)) 1583 1584 { 1584 if (theFile.attr_string) SH_FREE(theFile.attr_string); 1585 if (theFile.link_path) SH_FREE(theFile.link_path); 1585 if (theFile->attr_string) SH_FREE(theFile->attr_string); 1586 if (theFile->link_path) SH_FREE(theFile->link_path); 1587 SH_FREE(theFile); 1586 1588 SL_RETURN((0), _("sh_files_checkdir")); 1587 1589 } … … 1590 1592 { 1591 1593 SH_FREE(tmpname); 1592 if (theFile.attr_string) SH_FREE(theFile.attr_string); 1593 if (theFile.link_path) SH_FREE(theFile.link_path); 1594 SL_RETURN((-1), _("sh_files_checkdir")); 1595 } 1596 1597 if (theFile.c_mode[0] != 'd') 1594 if (theFile->attr_string) SH_FREE(theFile->attr_string); 1595 if (theFile->link_path) SH_FREE(theFile->link_path); 1596 SH_FREE(theFile); 1597 SL_RETURN((-1), _("sh_files_checkdir")); 1598 } 1599 1600 if (theFile->c_mode[0] != 'd') 1598 1601 { 1599 1602 sh_error_handle (ShDFLevel[SH_ERR_T_DIR], FIL__, __LINE__, 0, … … 1601 1604 tmpname); 1602 1605 SH_FREE(tmpname); 1603 if (theFile.attr_string) SH_FREE(theFile.attr_string); 1604 if (theFile.link_path) SH_FREE(theFile.link_path); 1606 if (theFile->attr_string) SH_FREE(theFile->attr_string); 1607 if (theFile->link_path) SH_FREE(theFile->link_path); 1608 SH_FREE(theFile); 1605 1609 SL_RETURN((-1), _("sh_files_checkdir")); 1606 1610 } 1607 1611 1608 hardlink_num = theFile.hardlinks; 1609 1612 hardlink_num = theFile->hardlinks; 1613 1614 if (theFile->attr_string) SH_FREE(theFile->attr_string); 1615 if (theFile->link_path) SH_FREE(theFile->link_path); 1616 SH_FREE(theFile); 1610 1617 1611 1618 /* ---- open directory for reading ---- … … 1623 1630 sh_error_message (status, errbuf, sizeof(errbuf)), tmpname); 1624 1631 SH_FREE(tmpname); 1625 1626 if (theFile.attr_string) SH_FREE(theFile.attr_string);1627 if (theFile.link_path) SH_FREE(theFile.link_path);1628 1632 SL_RETURN((-1), _("sh_files_checkdir")); 1629 1633 } 1630 1634 1631 theDir.NumRegular = 0; 1632 theDir.NumDirs = 0; 1633 theDir.NumSymlinks = 0; 1634 theDir.NumFifos = 0; 1635 theDir.NumSockets = 0; 1636 theDir.NumCDev = 0; 1637 theDir.NumBDev = 0; 1638 theDir.NumDoor = 0; 1639 theDir.NumPort = 0; 1640 theDir.NumAll = 0; 1641 theDir.TotalBytes = 0; 1642 sl_strlcpy (theDir.DirPath, iname, PATH_MAX); 1635 theDir = SH_ALLOC(sizeof(dir_type)); 1636 1637 theDir->NumRegular = 0; 1638 theDir->NumDirs = 0; 1639 theDir->NumSymlinks = 0; 1640 theDir->NumFifos = 0; 1641 theDir->NumSockets = 0; 1642 theDir->NumCDev = 0; 1643 theDir->NumBDev = 0; 1644 theDir->NumDoor = 0; 1645 theDir->NumPort = 0; 1646 theDir->NumAll = 0; 1647 theDir->TotalBytes = 0; 1648 sl_strlcpy (theDir->DirPath, iname, PATH_MAX); 1643 1649 1644 1650 … … 1654 1660 if (thisEntry != NULL) 1655 1661 { 1656 ++theDir .NumAll;1662 ++theDir->NumAll; 1657 1663 if (sl_strcmp (thisEntry->d_name, ".") == 0) 1658 1664 { 1659 ++theDir .NumDirs;1665 ++theDir->NumDirs; 1660 1666 continue; 1661 1667 } 1662 1668 if (sl_strcmp (thisEntry->d_name, "..") == 0) 1663 1669 { 1664 ++theDir .NumDirs;1670 ++theDir->NumDirs; 1665 1671 continue; 1666 1672 } … … 1686 1692 if (sig_termfast == 1) 1687 1693 { 1688 if (theFile.attr_string) SH_FREE(theFile.attr_string); 1689 if (theFile.link_path) SH_FREE(theFile.link_path); 1694 SH_FREE(theDir); 1690 1695 SL_RETURN((0), _("sh_files_checkdir")); 1691 1696 } … … 1769 1774 if (checkit == SH_FILE_DIRECTORY) 1770 1775 { 1771 ++theDir .NumDirs;1776 ++theDir->NumDirs; 1772 1777 } 1773 1778 SH_FREE(tmpcat); … … 1805 1810 1806 1811 if (checkit == SH_FILE_REGULAR) 1807 ++theDir .NumRegular;1812 ++theDir->NumRegular; 1808 1813 1809 1814 else if (checkit == SH_FILE_DIRECTORY) 1810 1815 { 1811 ++theDir .NumDirs;1816 ++theDir->NumDirs; 1812 1817 if (rdepth_next >= 0 && cchecked_flag != S_TRUE) 1813 1818 { … … 1870 1875 } 1871 1876 1872 else if (checkit == SH_FILE_SYMLINK) ++theDir .NumSymlinks;1873 else if (checkit == SH_FILE_FIFO) ++theDir .NumFifos;1874 else if (checkit == SH_FILE_SOCKET) ++theDir .NumSockets;1875 else if (checkit == SH_FILE_CDEV) ++theDir .NumCDev;1876 else if (checkit == SH_FILE_BDEV) ++theDir .NumBDev;1877 else if (checkit == SH_FILE_DOOR) ++theDir .NumDoor;1878 else if (checkit == SH_FILE_PORT) ++theDir .NumPort;1877 else if (checkit == SH_FILE_SYMLINK) ++theDir->NumSymlinks; 1878 else if (checkit == SH_FILE_FIFO) ++theDir->NumFifos; 1879 else if (checkit == SH_FILE_SOCKET) ++theDir->NumSockets; 1880 else if (checkit == SH_FILE_CDEV) ++theDir->NumCDev; 1881 else if (checkit == SH_FILE_BDEV) ++theDir->NumBDev; 1882 else if (checkit == SH_FILE_DOOR) ++theDir->NumDoor; 1883 else if (checkit == SH_FILE_PORT) ++theDir->NumPort; 1879 1884 1880 1885 SH_FREE(tmpcat); … … 1882 1887 if ((sig_termfast == 1) || (sig_terminate == 1)) 1883 1888 { 1884 if (theFile.attr_string) SH_FREE(theFile.attr_string); 1885 if (theFile.link_path) SH_FREE(theFile.link_path); 1889 SH_FREE(theDir); 1886 1890 SL_RETURN((0), _("sh_files_checkdir")); 1887 1891 } … … 1897 1901 { 1898 1902 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_FI_DSUM, 1899 theDir .NumDirs,1900 theDir .NumRegular,1901 theDir .NumSymlinks,1902 theDir .NumFifos,1903 theDir .NumSockets,1904 theDir .NumCDev,1905 theDir .NumBDev);1903 theDir->NumDirs, 1904 theDir->NumRegular, 1905 theDir->NumSymlinks, 1906 theDir->NumFifos, 1907 theDir->NumSockets, 1908 theDir->NumCDev, 1909 theDir->NumBDev); 1906 1910 } 1907 1911 … … 1912 1916 * Hardlink check; not done on MacOS X because of resource forks 1913 1917 */ 1914 if ((sh_check_hardlinks == S_TRUE) && (hardlink_num != theDir .NumDirs))1915 { 1916 if (0 != sh_files_hle_test(hardlink_num-theDir .NumDirs, iname))1918 if ((sh_check_hardlinks == S_TRUE) && (hardlink_num != theDir->NumDirs)) 1919 { 1920 if (0 != sh_files_hle_test(hardlink_num-theDir->NumDirs, iname)) 1917 1921 { 1918 1922 len = strlen(tmpname); … … 1922 1926 sl_snprintf(tmpcat, len, 1923 1927 _("%s: subdirectory count (%d) != hardlinks (%d)"), 1924 tmpname, theDir .NumDirs, hardlink_num);1928 tmpname, theDir->NumDirs, hardlink_num); 1925 1929 sh_error_handle (ShDFLevel[SH_ERR_T_DIR], FIL__, __LINE__, 0, 1926 1930 MSG_E_SUBGEN, tmpcat, _("sh_files_checkdir")); … … 1930 1934 #endif 1931 1935 1932 if (theFile.attr_string) SH_FREE(theFile.attr_string);1933 if (theFile.link_path) SH_FREE(theFile.link_path);1934 1936 SH_FREE(tmpname); 1937 SH_FREE(theDir); 1935 1938 1936 1939 SL_RETURN((0), _("sh_files_checkdir")); … … 1947 1950 /* 28 Aug 2001 allow NULL fileName 1948 1951 */ 1949 char fullpath[PATH_MAX];1952 char * fullpath; 1950 1953 char fileHash[2*(KEY_LEN + 1)]; 1951 1954 int status; 1952 file_type 1955 file_type * theFile; 1953 1956 char * tmpdir; 1954 1957 char * tmpname; … … 1956 1959 struct utimbuf utime_buf; 1957 1960 static unsigned int state = 1; 1961 char sc; 1958 1962 1959 1963 SL_ENTER(_("sh_files_filecheck")); 1964 1965 fullpath = SH_ALLOC(PATH_MAX); 1966 theFile = SH_ALLOC(sizeof(file_type)); 1960 1967 1961 1968 BREAKEXIT(sh_derr); … … 1982 1989 { 1983 1990 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_FI_NULL); 1991 SH_FREE(fullpath); 1992 SH_FREE(theFile); 1984 1993 SL_RETURN(SH_FILE_UNKNOWN, _("sh_files_filecheck")); 1985 1994 } … … 2020 2029 SH_FREE(tmpname); 2021 2030 SH_FREE(tmpdir); 2031 SH_FREE(fullpath); 2032 SH_FREE(theFile); 2022 2033 SL_RETURN(SH_FILE_UNKNOWN, _("sh_files_filecheck")); 2023 2034 } … … 2026 2037 /* stat the file and determine checksum (if a regular file) 2027 2038 */ 2028 sl_strlcpy (theFile .fullpath, fullpath, PATH_MAX);2029 theFile .check_mask = sh_files_maskof(class);2030 theFile .file_reported = (*reported);2031 theFile .attr_string = NULL;2032 theFile .link_path = NULL;2039 sl_strlcpy (theFile->fullpath, fullpath, PATH_MAX); 2040 theFile->check_mask = sh_files_maskof(class); 2041 theFile->file_reported = (*reported); 2042 theFile->attr_string = NULL; 2043 theFile->link_path = NULL; 2033 2044 2034 2045 TPT(( 0, FIL__, __LINE__, _("msg=<checking file: %s>\n"), fullpath)); … … 2037 2048 ShDFLevel[class] : ShDFLevel[SH_ERR_T_FILE], 2038 2049 fileName, 2039 &theFile, fileHash, class);2050 theFile, fileHash, class); 2040 2051 2041 2052 if (status != 0) … … 2045 2056 if (class == SH_LEVEL_ALLIGNORE && sh.flag.checkSum != SH_CHECK_INIT) 2046 2057 sh_hash_set_visited_true (fullpath); 2047 if (theFile.attr_string) SH_FREE(theFile.attr_string); 2048 if (theFile.link_path) SH_FREE(theFile.link_path); 2058 if (theFile->attr_string) SH_FREE(theFile->attr_string); 2059 if (theFile->link_path) SH_FREE(theFile->link_path); 2060 SH_FREE(fullpath); 2061 SH_FREE(theFile); 2049 2062 SL_RETURN(SH_FILE_UNKNOWN, _("sh_files_filecheck")); 2050 2063 } … … 2056 2069 /* report 2057 2070 */ 2058 if ((flag_err_debug == SL_TRUE) && (theFile .c_mode[0] == '-'))2071 if ((flag_err_debug == SL_TRUE) && (theFile->c_mode[0] == '-')) 2059 2072 { 2060 2073 tmpname = sh_util_safe_name (fullpath); /* fixed in 1.5.4 */ … … 2067 2080 if ( sh.flag.checkSum == SH_CHECK_INIT /* && sh.flag.update == S_FALSE */) 2068 2081 { 2069 sh_hash_pushdata ( &theFile, fileHash);2082 sh_hash_pushdata (theFile, fileHash); 2070 2083 } 2071 2084 else if (sh.flag.checkSum == SH_CHECK_CHECK … … 2074 2087 ) 2075 2088 { 2076 sh_hash_compdata (class, &theFile, fileHash, NULL, -1);2089 sh_hash_compdata (class, theFile, fileHash, NULL, -1); 2077 2090 } 2078 2091 2079 (*reported) = theFile .file_reported;2092 (*reported) = theFile->file_reported; 2080 2093 2081 2094 /* reset the access time 2082 2095 */ 2083 if (class == SH_LEVEL_NOIGNORE && (theFile .check_mask & MODI_ATM) != 0)2084 { 2085 utime_buf.actime = (time_t) theFile .atime;2086 utime_buf.modtime = (time_t) theFile .mtime;2096 if (class == SH_LEVEL_NOIGNORE && (theFile->check_mask & MODI_ATM) != 0) 2097 { 2098 utime_buf.actime = (time_t) theFile->atime; 2099 utime_buf.modtime = (time_t) theFile->mtime; 2087 2100 #if !defined(O_NOATIME) 2088 2101 retry_aud_utime (FIL__, __LINE__, fullpath, &utime_buf); … … 2094 2107 * Check for resource fork 2095 2108 */ 2096 if ( (theFile .c_mode[0] != 'd') && (rsrcflag == 0) )2109 if ( (theFile->c_mode[0] != 'd') && (rsrcflag == 0) ) 2097 2110 { 2098 2111 int dummy; 2099 2112 static int rsrc_init = 0; 2100 2113 static char rsrc[17]; 2101 char testpath [PATH_MAX];2114 char testpath = SH_ALLOC(PATH_MAX); 2102 2115 2103 2116 if (rsrc_init == 0) { … … 2116 2129 } 2117 2130 } 2131 SH_FREE(testpath); 2118 2132 } 2119 2133 #else … … 2123 2137 ret_point: 2124 2138 2125 if (theFile.attr_string) SH_FREE(theFile.attr_string); 2126 if (theFile.link_path) SH_FREE(theFile.link_path); 2127 2128 switch (theFile.c_mode[0]) 2139 sc = theFile->c_mode[0]; 2140 2141 if (theFile->attr_string) SH_FREE(theFile->attr_string); 2142 if (theFile->link_path) SH_FREE(theFile->link_path); 2143 SH_FREE(fullpath); 2144 SH_FREE(theFile); 2145 2146 switch (sc) 2129 2147 { 2130 2148 case '-': SL_RETURN(SH_FILE_REGULAR, _("sh_files_filecheck")); -
trunk/src/sh_gpg.c
r203 r227 295 295 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 296 296 struct passwd pwd; 297 char buffer[SH_PWBUF_SIZE];297 char * buffer = SH_ALLOC(SH_PWBUF_SIZE); 298 298 struct passwd * tempres; 299 sh_getpwnam_r(DEFAULT_IDENT, &pwd, buffer, sizeof(buffer), &tempres);299 sh_getpwnam_r(DEFAULT_IDENT, &pwd, buffer, SH_PWBUF_SIZE, &tempres); 300 300 #else 301 301 struct passwd * tempres = sh_getpwnam(DEFAULT_IDENT); … … 363 363 sl_strlcpy (cc4, tempres->pw_dir, SH_PATHBUF+32); 364 364 sl_strlcat (cc4, _("/.gnupg"), SH_PATHBUF+32); 365 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 366 SH_FREE(buffer); 367 #endif 365 368 } 366 369 #endif … … 964 967 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 965 968 struct passwd pwd; 966 char buffer[SH_PWBUF_SIZE];969 char * buffer = SH_ALLOC(SH_PWBUF_SIZE); 967 970 #endif 968 971 #endif … … 989 992 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_EXIT_ABORT1, sh.prg_name); 990 993 aud_exit (FIL__, __LINE__, EXIT_FAILURE); 994 #if defined(SH_WITH_SERVER) 995 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 996 SH_FREE(buffer); 997 #endif 998 #endif 991 999 SL_RETURN( (-1), _("sh_gpg_check_sign")); 992 1000 } … … 997 1005 #if defined(SH_WITH_SERVER) 998 1006 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 999 sh_getpwnam_r(DEFAULT_IDENT, &pwd, buffer, sizeof(buffer), &tempres);1007 sh_getpwnam_r(DEFAULT_IDENT, &pwd, buffer, SH_PWBUF_SIZE, &tempres); 1000 1008 #else 1001 1009 tempres = sh_getpwnam(DEFAULT_IDENT); … … 1018 1026 #if defined(SH_WITH_SERVER) 1019 1027 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 1020 sh_getpwnam_r(DEFAULT_IDENT, &pwd, buffer, sizeof(buffer), &tempres);1028 sh_getpwnam_r(DEFAULT_IDENT, &pwd, buffer, SH_PWBUF_SIZE, &tempres); 1021 1029 #else 1022 1030 tempres = sh_getpwnam(DEFAULT_IDENT); … … 1065 1073 } 1066 1074 smsg = S_TRUE; 1075 #if defined(SH_WITH_SERVER) 1076 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 1077 SH_FREE(buffer); 1078 #endif 1079 #endif 1067 1080 SL_RETURN(0, _("sh_gpg_check_sign")); 1068 1081 } … … 1093 1106 } 1094 1107 smsg = S_TRUE; 1108 #if defined(SH_WITH_SERVER) 1109 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 1110 SH_FREE(buffer); 1111 #endif 1112 #endif 1095 1113 SL_RETURN(0, _("sh_gpg_check_sign")); 1096 1114 #endif … … 1102 1120 (sl_strcmp(gp.data_fp, gp.conf_fp) == 0)) 1103 1121 { 1122 #if defined(SH_WITH_SERVER) 1123 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 1124 SH_FREE(buffer); 1125 #endif 1126 #endif 1104 1127 SL_RETURN(0, _("sh_gpg_check_sign")); 1105 1128 } … … 1131 1154 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 1132 1155 struct passwd e_pwd; 1133 char e_buffer[SH_PWBUF_SIZE];1156 char * e_buffer = SH_ALLOC(SH_PWBUF_SIZE); 1134 1157 struct passwd * e_tempres; 1135 sh_getpwnam_r(DEFAULT_IDENT, &e_pwd, e_buffer, sizeof(e_buffer), &e_tempres);1158 sh_getpwnam_r(DEFAULT_IDENT, &e_pwd, e_buffer, SH_PWBUF_SIZE, &e_tempres); 1136 1159 #else 1137 1160 struct passwd * e_tempres = sh_getpwnam(DEFAULT_IDENT); … … 1153 1176 #endif 1154 1177 (int) e_uid, e_home); 1178 1179 #if defined(SH_WITH_SERVER) 1180 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 1181 SH_FREE(e_buffer); 1182 #endif 1183 #endif 1155 1184 } 1156 1185 -
trunk/src/sh_hash.c
r212 r227 1338 1338 --sig_raised; --sig_urgent; 1339 1339 retval = 1; exitval = EXIT_SUCCESS; 1340 SH_FREE(line); 1341 line = NULL; 1340 1342 goto unlock_and_return; 1341 1343 } … … 2173 2175 unsigned char * str, int size) 2174 2176 { 2175 file_type tmpFile;2176 2177 int i = 0; 2177 2178 char * p; 2178 2179 char i2h[2]; 2179 2180 tmpFile.attr_string = NULL; 2181 tmpFile.link_path = NULL; 2182 2183 sl_strlcpy(tmpFile.fullpath, key, PATH_MAX); 2184 tmpFile.size = val1; 2185 tmpFile.mtime = val2; 2186 tmpFile.ctime = val3; 2187 2188 tmpFile.atime = 0; 2189 tmpFile.mode = 0; 2190 tmpFile.owner = 0; 2191 tmpFile.group = 0; 2192 sl_strlcpy(tmpFile.c_owner, _("root"), 5); 2193 sl_strlcpy(tmpFile.c_group, _("root"), 5); 2180 file_type * tmpFile = SH_ALLOC(sizeof(file_type)); 2181 2182 tmpFile->attr_string = NULL; 2183 tmpFile->link_path = NULL; 2184 2185 sl_strlcpy(tmpFile->fullpath, key, PATH_MAX); 2186 tmpFile->size = val1; 2187 tmpFile->mtime = val2; 2188 tmpFile->ctime = val3; 2189 2190 tmpFile->atime = 0; 2191 tmpFile->mode = 0; 2192 tmpFile->owner = 0; 2193 tmpFile->group = 0; 2194 sl_strlcpy(tmpFile->c_owner, _("root"), 5); 2195 sl_strlcpy(tmpFile->c_group, _("root"), 5); 2194 2196 2195 2197 if ((str != NULL) && (size < (PATH_MAX/2)-1)) 2196 2198 { 2197 tmpFile .c_mode[0] = 'l';2198 tmpFile .c_mode[1] = 'r'; tmpFile.c_mode[2] = 'w';2199 tmpFile .c_mode[3] = 'x'; tmpFile.c_mode[4] = 'r';2200 tmpFile .c_mode[5] = 'w'; tmpFile.c_mode[6] = 'x';2201 tmpFile .c_mode[7] = 'r'; tmpFile.c_mode[8] = 'w';2202 tmpFile .c_mode[9] = 'x'; tmpFile.c_mode[10] = '\0';2203 tmpFile .link_path = SH_ALLOC((size * 2) + 2);2199 tmpFile->c_mode[0] = 'l'; 2200 tmpFile->c_mode[1] = 'r'; tmpFile->c_mode[2] = 'w'; 2201 tmpFile->c_mode[3] = 'x'; tmpFile->c_mode[4] = 'r'; 2202 tmpFile->c_mode[5] = 'w'; tmpFile->c_mode[6] = 'x'; 2203 tmpFile->c_mode[7] = 'r'; tmpFile->c_mode[8] = 'w'; 2204 tmpFile->c_mode[9] = 'x'; tmpFile->c_mode[10] = '\0'; 2205 tmpFile->link_path = SH_ALLOC((size * 2) + 2); 2204 2206 for (i = 0; i < size; ++i) 2205 2207 { 2206 2208 p = sh_util_charhex (str[i],i2h); 2207 tmpFile .link_path[2*i] = p[0];2208 tmpFile .link_path[2*i+1] = p[1];2209 tmpFile .link_path[2*i+2] = '\0';2209 tmpFile->link_path[2*i] = p[0]; 2210 tmpFile->link_path[2*i+1] = p[1]; 2211 tmpFile->link_path[2*i+2] = '\0'; 2210 2212 } 2211 2213 } … … 2213 2215 { 2214 2216 for (i = 0; i < 10; ++i) 2215 tmpFile .c_mode[i] = '-';2216 tmpFile .c_mode[10] = '\0';2217 tmpFile .link_path = sh_util_strdup("-");2217 tmpFile->c_mode[i] = '-'; 2218 tmpFile->c_mode[10] = '\0'; 2219 tmpFile->link_path = sh_util_strdup("-"); 2218 2220 } 2219 2221 2220 2222 if (sh.flag.checkSum == SH_CHECK_CHECK && 2221 2223 sh.flag.update == S_TRUE) 2222 sh_hash_pushdata_memory (&tmpFile, SH_KEY_NULL); 2223 else 2224 sh_hash_pushdata (&tmpFile, SH_KEY_NULL); 2225 2226 if (tmpFile.link_path) SH_FREE(tmpFile.link_path); 2224 sh_hash_pushdata_memory (tmpFile, SH_KEY_NULL); 2225 else 2226 sh_hash_pushdata (tmpFile, SH_KEY_NULL); 2227 2228 if (tmpFile->link_path) SH_FREE(tmpFile->link_path); 2229 SH_FREE(tmpFile); 2227 2230 return; 2228 2231 } … … 2234 2237 int * size) 2235 2238 { 2236 file_type tmpFile;2237 2239 size_t len; 2238 2240 char * p; 2239 2241 int i; 2240 2242 char * retval = NULL; 2243 file_type * tmpFile = SH_ALLOC(sizeof(file_type)); 2241 2244 2242 2245 *size = 0; 2243 2246 2244 if (0 == sh_hash_get_it (key, &tmpFile))2245 { 2246 *val1 = tmpFile .size;2247 *val2 = tmpFile .mtime;2248 *val3 = tmpFile .ctime;2249 2250 if (tmpFile .link_path && tmpFile.link_path[0] != '-')2251 { 2252 len = strlen(tmpFile .link_path);2247 if (0 == sh_hash_get_it (key, tmpFile)) 2248 { 2249 *val1 = tmpFile->size; 2250 *val2 = tmpFile->mtime; 2251 *val3 = tmpFile->ctime; 2252 2253 if (tmpFile->link_path && tmpFile->link_path[0] != '-') 2254 { 2255 len = strlen(tmpFile->link_path); 2253 2256 2254 2257 p = SH_ALLOC((len/2)+1); 2255 i = sh_util_hextobinary (p, tmpFile .link_path, len);2258 i = sh_util_hextobinary (p, tmpFile->link_path, len); 2256 2259 2257 2260 if (i == 0) … … 2279 2282 *val3 = 0; 2280 2283 } 2281 if (tmpFile.link_path) SH_FREE(tmpFile.link_path); 2284 if (tmpFile->link_path) SH_FREE(tmpFile->link_path); 2285 SH_FREE(tmpFile); 2282 2286 return retval; 2283 2287 } … … 3990 3994 decompressed[clen] = '\0'; 3991 3995 fputs( (char*) decompressed, stdout); 3996 SH_FREE(decompressed); 3992 3997 return 0; 3993 3998 } -
trunk/src/sh_prelude.c
r206 r227 707 707 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 708 708 struct passwd pwd; 709 char buffer[SH_PWBUF_SIZE];709 char * buffer; 710 710 #endif 711 711 … … 896 896 897 897 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 898 sh_getpwnam_r(ptr, &pwd, buffer, sizeof(buffer), &pw); 898 buffer = SH_ALLOC(SH_PWBUF_SIZE); 899 sh_getpwnam_r(ptr, &pwd, buffer, SH_PWBUF_SIZE, &pw); 899 900 #else 900 901 pw = sh_getpwnam(ptr); … … 906 907 if ( ret < 0 ) { 907 908 free(ptr); 909 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 910 SH_FREE(buffer); 911 #endif 908 912 return ret; 909 913 } 910 914 prelude_string_set_nodup(str, ptr); 911 915 916 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 917 SH_FREE(buffer); 918 #endif 912 919 } 920 913 921 914 922 ptr = get_value(msg, _("path"), NULL); … … 967 975 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 968 976 struct passwd pwd; 969 char buffer[SH_PWBUF_SIZE];977 char * buffer; 970 978 #endif 971 979 prelude_string_t *str; … … 1054 1062 1055 1063 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 1056 sh_getpwnam_r(ptr, &pwd, buffer, sizeof(buffer), &pw); 1064 buffer = SH_ALLOC(SH_PWBUF_SIZE); 1065 sh_getpwnam_r(ptr, &pwd, buffer, SH_PWBUF_SIZE, &pw); 1057 1066 #else 1058 1067 pw = sh_getpwnam(ptr); … … 1064 1073 if ( ret < 0 ) { 1065 1074 free(ptr); 1075 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 1076 SH_FREE(buffer); 1077 #endif 1066 1078 return ret; 1067 1079 } … … 1073 1085 if ( ret < 0 ) { 1074 1086 free(ptr); 1087 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 1088 SH_FREE(buffer); 1089 #endif 1075 1090 return ret; 1076 1091 } … … 1078 1093 prelude_string_set_nodup(str, ptr); 1079 1094 } 1095 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 1096 SH_FREE(buffer); 1097 #endif 1080 1098 } 1081 1099 -
trunk/src/sh_suidchk.c
r199 r227 860 860 char * fs; 861 861 long sl_status; 862 file_type theFile;862 file_type * theFile = NULL; 863 863 char fileHash[2*(KEY_LEN + 1)]; 864 864 … … 959 959 _("sh_suidchk_check_internal"), tmp ); 960 960 SH_FREE(tmp); 961 SH_FREE(tmpcat); 961 962 dirlist = dirlist->next; 962 963 continue; … … 1032 1033 ) 1033 1034 { 1034 1035 (void) sl_strlcpy (theFile.fullpath, tmpcat, PATH_MAX); 1036 theFile.check_mask = sh_files_maskof(SH_LEVEL_READONLY); 1037 CLEAR_SH_FFLAG_REPORTED(theFile.file_reported); 1038 theFile.attr_string = NULL; 1039 theFile.link_path = NULL; 1035 theFile = SH_ALLOC(sizeof(file_type)); 1036 1037 (void) sl_strlcpy (theFile->fullpath, tmpcat, PATH_MAX); 1038 theFile->check_mask = sh_files_maskof(SH_LEVEL_READONLY); 1039 CLEAR_SH_FFLAG_REPORTED(theFile->file_reported); 1040 theFile->attr_string = NULL; 1041 theFile->link_path = NULL; 1040 1042 1041 1043 status = sh_unix_getinfo (ShDFLevel[SH_ERR_T_RO], 1042 1044 dirlist->sh_d_name, 1043 &theFile, fileHash, 0);1045 theFile, fileHash, 0); 1044 1046 1045 1047 tmp = sh_util_safe_name(tmpcat); … … 1076 1078 1077 1079 if (0 == sh_hash_compdata (SH_LEVEL_READONLY, 1078 &theFile, fileHash,1080 theFile, fileHash, 1079 1081 _("[SuidCheck]"), 1080 1082 ShSuidchkSeverity)) 1081 1083 { 1082 sh_hash_pushdata_memory ( &theFile, fileHash);1084 sh_hash_pushdata_memory (theFile, fileHash); 1083 1085 } 1084 1086 … … 1092 1094 /* Running init. Report on files detected. 1093 1095 */ 1094 sh_hash_pushdata ( &theFile, fileHash);1096 sh_hash_pushdata (theFile, fileHash); 1095 1097 sh_error_handle ((-1), FIL__, __LINE__, 1096 1098 0, MSG_SUID_FOUND, tmp ); … … 1111 1113 if (-1 == fflags) 1112 1114 { 1113 (void) sh_unix_gmttime (theFile .ctime, timestrc, sizeof(timestrc));1114 (void) sh_unix_gmttime (theFile .atime, timestra, sizeof(timestra));1115 (void) sh_unix_gmttime (theFile .mtime, timestrm, sizeof(timestrm));1116 1117 report_file(tmpcat, &theFile, timestrc, timestra, timestrm);1115 (void) sh_unix_gmttime (theFile->ctime, timestrc, sizeof(timestrc)); 1116 (void) sh_unix_gmttime (theFile->atime, timestra, sizeof(timestra)); 1117 (void) sh_unix_gmttime (theFile->mtime, timestrm, sizeof(timestrm)); 1118 1119 report_file(tmpcat, theFile, timestrc, timestra, timestrm); 1118 1120 } 1119 1121 /* Quarantine file according to configured method … … 1124 1126 { 1125 1127 case SH_Q_DELETE: 1126 sh_q_delete(theFile .fullpath);1128 sh_q_delete(theFile->fullpath); 1127 1129 break; 1128 1130 case SH_Q_CHANGEPERM: 1129 sh_q_changeperm(theFile .fullpath);1131 sh_q_changeperm(theFile->fullpath); 1130 1132 break; 1131 1133 case SH_Q_MOVE: 1132 sh_q_move(theFile .fullpath, &theFile, timestrc, timestra, timestrm);1134 sh_q_move(theFile->fullpath, theFile, timestrc, timestra, timestrm); 1133 1135 break; 1134 1136 default: … … 1144 1146 */ 1145 1147 (void) sh_hash_compdata (SH_LEVEL_READONLY, 1146 &theFile, fileHash,1148 theFile, fileHash, 1147 1149 _("[SuidCheck]"), 1148 1150 ShSuidchkSeverity); … … 1157 1159 */ 1158 1160 (void) sh_hash_compdata (SH_LEVEL_READONLY, 1159 &theFile, fileHash,1161 theFile, fileHash, 1160 1162 _("[SuidCheck]"), 1161 1163 ShSuidchkSeverity); … … 1167 1169 } 1168 1170 SH_FREE(tmp); 1169 if (theFile.attr_string) SH_FREE(theFile.attr_string); 1170 if (theFile.link_path) SH_FREE(theFile.link_path); 1171 if (theFile->attr_string) SH_FREE(theFile->attr_string); 1172 if (theFile->link_path) SH_FREE(theFile->link_path); 1173 SH_FREE(theFile); 1171 1174 } 1172 1175 } -
trunk/src/sh_unix.c
r221 r227 990 990 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 991 991 struct passwd pwd; 992 char buffer[SH_PWBUF_SIZE];992 char * buffer; 993 993 #endif 994 994 … … 998 998 */ 999 999 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 1000 sh_getpwnam_r(c, &pwd, buffer, sizeof(buffer), &w); 1000 buffer = SH_ALLOC(SH_PWBUF_SIZE); 1001 sh_getpwnam_r(c, &pwd, buffer, SH_PWBUF_SIZE, &w); 1001 1002 #else 1002 1003 w = sh_getpwnam(c); … … 1014 1015 sh_error_handle ((-1), FIL__, __LINE__, EINVAL, MSG_EINVALS, 1015 1016 _("add trusted user"), c); 1017 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 1018 SH_FREE(buffer); 1019 #endif 1016 1020 SL_RETURN((-1), _("tf_add_trusted_user_int")); 1017 1021 1018 1022 succe: 1019 1023 count = sl_trust_add_user(pwid); 1024 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 1025 SH_FREE(buffer); 1026 #endif 1020 1027 SL_RETURN((count), _("tf_add_trusted_user_int")); 1021 1028 } … … 1092 1099 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 1093 1100 struct passwd pwd; 1094 char buffer[SH_PWBUF_SIZE];1101 char * buffer = SH_ALLOC(SH_PWBUF_SIZE); 1095 1102 struct passwd * tempres; 1096 sh_getpwnam_r(DEFAULT_IDENT, &pwd, buffer, sizeof(buffer), &tempres);1103 sh_getpwnam_r(DEFAULT_IDENT, &pwd, buffer, SH_PWBUF_SIZE, &tempres); 1097 1104 #else 1098 1105 struct passwd * tempres = sh_getpwnam(DEFAULT_IDENT); … … 1107 1114 } 1108 1115 ff_euid = tempres->pw_uid; 1116 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 1117 SH_FREE(buffer); 1118 #endif 1109 1119 } 1110 1120 #endif … … 2469 2479 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWUID_R) 2470 2480 struct passwd pwd; 2471 char buffer[SH_PWBUF_SIZE];2481 char * buffer; 2472 2482 #endif 2473 2483 char errbuf[SH_ERRBUF_SIZE]; … … 2476 2486 2477 2487 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWUID_R) 2478 sh_getpwuid_r(uid, &pwd, buffer, sizeof(buffer), &tempres); 2488 buffer = SH_ALLOC(SH_PWBUF_SIZE); 2489 sh_getpwuid_r(uid, &pwd, buffer, SH_PWBUF_SIZE, &tempres); 2479 2490 #else 2480 2491 errno = 0; … … 2487 2498 sh_error_message(status, errbuf, sizeof(errbuf)), 2488 2499 _("getpwuid"), (long) uid, _("completely missing")); 2500 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) 2501 SH_FREE(buffer); 2502 #endif 2489 2503 SL_RETURN( NULL, _("sh_unix_getUIDdir")); 2490 2504 } … … 2492 2506 if (tempres->pw_dir != NULL) { 2493 2507 sl_strlcpy(out, tempres->pw_dir, len); 2508 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) 2509 SH_FREE(buffer); 2510 #endif 2494 2511 SL_RETURN( out, _("sh_unix_getUIDdir")); 2495 2512 } else { … … 2497 2514 sh_error_message(status, errbuf, sizeof(errbuf)), 2498 2515 _("getpwuid"), (long) uid, _("pw_dir")); 2516 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) 2517 SH_FREE(buffer); 2518 #endif 2499 2519 SL_RETURN( NULL, _("sh_unix_getUIDdir")); 2500 2520 } … … 2508 2528 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWUID_R) 2509 2529 struct passwd pwd; 2510 char buffer[SH_PWBUF_SIZE];2530 char * buffer; 2511 2531 #endif 2512 2532 int status = 0; … … 2529 2549 2530 2550 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWUID_R) 2531 sh_getpwuid_r(uid, &pwd, buffer, sizeof(buffer), &tempres); 2551 buffer = SH_ALLOC(SH_PWBUF_SIZE); 2552 sh_getpwuid_r(uid, &pwd, buffer, SH_PWBUF_SIZE, &tempres); 2532 2553 #else 2533 2554 errno = 0; … … 2540 2561 sh_error_message(status, errbuf, sizeof(errbuf)), 2541 2562 _("getpwuid"), (long) uid, _("completely missing")); 2563 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) 2564 SH_FREE(buffer); 2565 #endif 2542 2566 SL_RETURN( NULL, _("sh_unix_getUIDname")); 2543 2567 } … … 2550 2574 sl_strlcpy(out, name, len); 2551 2575 SH_MUTEX_UNLOCK_UNSAFE(mutex_getUIDname); 2576 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) 2577 SH_FREE(buffer); 2578 #endif 2552 2579 SL_RETURN( out, _("sh_unix_getUIDname")); 2553 2580 } else { … … 2555 2582 sh_error_message(status, errbuf, sizeof(errbuf)), 2556 2583 _("getpwuid"), (long) uid, _("pw_user")); 2584 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) 2585 SH_FREE(buffer); 2586 #endif 2557 2587 SL_RETURN( NULL, _("sh_unix_getUIDname")); 2558 2588 } … … 2569 2599 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) 2570 2600 struct group grp; 2571 char buffer[SH_GRBUF_SIZE];2601 char * buffer; 2572 2602 #endif 2573 2603 char errbuf[SH_ERRBUF_SIZE]; … … 2588 2618 2589 2619 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) 2590 status = sh_getgrgid_r(gid, &grp, buffer, sizeof(buffer), &tempres); 2620 buffer = SH_ALLOC(SH_GRBUF_SIZE); 2621 status = sh_getgrgid_r(gid, &grp, buffer, SH_GRBUF_SIZE, &tempres); 2591 2622 #else 2592 2623 errno = 0; … … 2600 2631 _("getgrgid"), (long) gid, _("completely missing")); 2601 2632 2633 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) 2634 SH_FREE(buffer); 2635 #endif 2602 2636 SL_RETURN( NULL, _("sh_unix_getGIDname")); 2603 2637 } … … 2609 2643 sl_strlcpy(out, name, len); 2610 2644 SH_MUTEX_UNLOCK_UNSAFE(mutex_getGIDname); 2645 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) 2646 SH_FREE(buffer); 2647 #endif 2611 2648 SL_RETURN( out, _("sh_unix_getGIDname")); 2612 2649 } else { … … 2614 2651 sh_error_message(status, errbuf, sizeof(errbuf)), 2615 2652 _("getgrgid"), (long) gid, _("gr_name")); 2653 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) 2654 SH_FREE(buffer); 2655 #endif 2616 2656 SL_RETURN( NULL, _("sh_unix_getGIDname")); 2617 2657 } … … 3136 3176 char * fileHash, int alert_timeout, SL_TICKET fd) 3137 3177 { 3138 file_type tmpFile;3178 file_type * tmpFile; 3139 3179 int status; 3140 3180 3141 3181 SL_ENTER(_("sh_unix_checksum_size")); 3142 3182 3143 tmpFile.link_path = NULL; 3183 tmpFile = SH_ALLOC(sizeof(file_type)); 3184 tmpFile->link_path = NULL; 3144 3185 3145 3186 if (sh.flag.checkSum != SH_CHECK_INIT) 3146 3187 { 3147 3188 /* lookup file in database */ 3148 status = sh_hash_get_it (filename, &tmpFile);3189 status = sh_hash_get_it (filename, tmpFile); 3149 3190 if (status != 0) { 3150 3191 goto out; … … 3153 3194 else 3154 3195 { 3155 tmpFile .size = fbuf->st_size;3196 tmpFile->size = fbuf->st_size; 3156 3197 } 3157 3198 3158 3199 /* if last < current get checksum */ 3159 if (tmpFile .size < fbuf->st_size)3200 if (tmpFile->size < fbuf->st_size) 3160 3201 { 3161 3202 char hashbuf[KEYBUF_SIZE]; 3162 UINT64 local_length = (UINT64) (tmpFile .size < 0 ? 0 : tmpFile.size);3203 UINT64 local_length = (UINT64) (tmpFile->size < 0 ? 0 : tmpFile->size); 3163 3204 sl_strlcpy(fileHash, 3164 3205 sh_tiger_generic_hash (filename, fd, &(local_length), … … 3167 3208 3168 3209 /* return */ 3169 if (tmpFile.link_path) SH_FREE(tmpFile.link_path); 3210 if (tmpFile->link_path) SH_FREE(tmpFile->link_path); 3211 SH_FREE(tmpFile); 3170 3212 SL_RETURN( 0, _("sh_unix_checksum_size")); 3171 3213 } 3172 3214 3173 3215 out: 3174 if (tmpFile.link_path) SH_FREE(tmpFile.link_path); 3216 if (tmpFile->link_path) SH_FREE(tmpFile->link_path); 3217 SH_FREE(tmpFile); 3175 3218 sl_strlcpy(fileHash, SH_KEY_NULL, KEY_LEN+1); 3176 3219 SL_RETURN( -1, _("sh_unix_checksum_size")); -
trunk/src/sh_userfiles.c
r203 r227 251 251 struct userhomeslist *new; 252 252 struct userhomeslist *homes; 253 char * filepath; 253 254 (void) arg; 254 255 … … 297 298 SH_MUTEX_UNLOCK(mutex_pwent); 298 299 300 filepath = SH_ALLOC(PATH_MAX); 301 299 302 for (homes = userHomes; homes != NULL; homes = homes->next ) { 300 303 struct userfileslist *file_ptr; 301 char filepath[PATH_MAX];302 304 303 305 for (file_ptr = userFiles; file_ptr != NULL; file_ptr = file_ptr->next) { … … 348 350 } 349 351 } 352 353 SH_FREE(filepath); 350 354 351 355 SL_RETURN(0, _("sh_userfiles_init")); -
trunk/src/slib.c
r214 r227 1473 1473 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 1474 1474 struct passwd pwd; 1475 char buffer[SH_PWBUF_SIZE];1475 char * buffer; 1476 1476 struct passwd * tempres; 1477 sh_getpwnam_r(user, &pwd, buffer, sizeof(buffer), &tempres); 1477 buffer = malloc(SH_PWBUF_SIZE); 1478 SL_REQUIRE (buffer != NULL, _("buffer != NULL")); 1479 sh_getpwnam_r(user, &pwd, buffer, SH_PWBUF_SIZE, &tempres); 1478 1480 #else 1479 1481 struct passwd * tempres = sh_getpwnam(user); … … 1484 1486 rgid_orig = tempres->pw_gid; 1485 1487 ruid_orig = tempres->pw_uid; 1488 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 1489 free(buffer); 1490 #endif 1486 1491 } 1487 1492 else … … 1516 1521 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 1517 1522 struct passwd pwd; 1518 char buffer[SH_PWBUF_SIZE];1523 char * buffer; 1519 1524 struct passwd * tempres; 1520 sh_getpwnam_r(user, &pwd, buffer, sizeof(buffer), &tempres); 1525 buffer = malloc(SH_PWBUF_SIZE); 1526 SL_REQUIRE (buffer != NULL, _("buffer != NULL")); 1527 sh_getpwnam_r(user, &pwd, buffer, SH_PWBUF_SIZE, &tempres); 1521 1528 #else 1522 1529 struct passwd * tempres = sh_getpwnam(user); … … 1527 1534 SL_REQUIRE (sl_drop_privileges() == SL_ENONE, 1528 1535 _("sl_drop_privileges() == SL_ENONE")); 1536 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 1537 free(buffer); 1538 #endif 1529 1539 } 1530 1540 SL_IRETURN(SL_ENONE, _("sl_policy_get_user")); -
trunk/src/trustfile.c
r221 r227 422 422 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) 423 423 struct group gr; 424 char buffer[SH_GRBUF_SIZE];424 char * buffer = NULL; 425 425 struct passwd pwd; 426 char pbuffer[SH_PWBUF_SIZE];426 char * pbuffer = NULL; 427 427 #endif 428 428 … … 430 430 431 431 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) 432 sh_getgrgid_r(grp, &gr, buffer, sizeof(buffer), &g); 432 buffer = malloc(SH_GRBUF_SIZE); 433 sh_getgrgid_r(grp, &gr, buffer, SH_GRBUF_SIZE, &g); 433 434 #else 434 435 g = sh_getgrgid(grp); … … 437 438 if (g == NULL) 438 439 { 439 SL_IRETURN(SL_FALSE, _("isingrp") ); 440 } 441 /* 442 if(g->gr_mem == NULL || g->gr_mem[0] == NULL ) 443 SL_IRETURN(SL_FALSE, _("isingrp") ); 444 */ 440 goto end_false; 441 } 445 442 446 443 /* this will return at the first match 447 444 */ 445 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) 446 pbuffer = malloc(SH_PWBUF_SIZE); 447 #endif 448 448 449 for(p = g->gr_mem; *p != NULL; p++) 449 450 { … … 452 453 /* map user name to UID and compare */ 453 454 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 454 sh_getpwnam_r(*p, &pwd, pbuffer, sizeof(pbuffer), &w);455 sh_getpwnam_r(*p, &pwd, pbuffer, SH_PWBUF_SIZE, &w); 455 456 #else 456 457 w = sh_getpwnam(*p); … … 459 460 #ifdef TRUST_MAIN 460 461 if (w != NULL && *u == (uid_t)(w->pw_uid) ) 461 SL_IRETURN(SL_TRUE, _("isingrp"));462 goto end_true; 462 463 #else 463 464 if (w != NULL && *u == (uid_t)(w->pw_uid) ) 464 465 { 465 SL_IRETURN(SL_TRUE, _("isingrp"));466 goto end_true; 466 467 } 467 468 #endif … … 474 475 { 475 476 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWUID_R) 476 sh_getpwuid_r(*u, &pwd, pbuffer, sizeof(pbuffer), &w);477 sh_getpwuid_r(*u, &pwd, pbuffer, SH_PWBUF_SIZE, &w); 477 478 #else 478 479 w = sh_getpwuid(*u); … … 480 481 #ifdef TRUST_MAIN 481 482 if (w != NULL && grp == (gid_t)(w->pw_gid) ) 482 SL_IRETURN(SL_TRUE, _("isingrp"));483 goto end_true; 483 484 #else 484 485 if (w != NULL && grp == (gid_t)(w->pw_gid) ) 485 486 { 486 SL_IRETURN(SL_TRUE, _("isingrp")); 487 } 488 #endif 489 } 490 487 goto end_true; 488 } 489 #endif 490 } 491 492 end_false: 493 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) 494 if (buffer) free(buffer); 495 if (pbuffer) free(pbuffer); 496 #endif 491 497 SL_IRETURN(SL_FALSE, _("isingrp")); 498 499 end_true: 500 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) 501 if (buffer) free(buffer); 502 if (pbuffer) free(pbuffer); 503 #endif 504 SL_IRETURN(SL_TRUE, _("isingrp")); 492 505 } 493 506 … … 506 519 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) 507 520 struct group gr; 508 char buffer[SH_GRBUF_SIZE];521 char * buffer = NULL; 509 522 struct passwd pw; 510 char pbuffer[SH_PWBUF_SIZE];523 char * pbuffer = NULL; 511 524 #endif 512 525 … … 521 534 522 535 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) 523 sh_getgrgid_r(grp, &gr, buffer, sizeof(buffer), &g); 536 buffer = malloc(SH_GRBUF_SIZE); 537 sh_getgrgid_r(grp, &gr, buffer, SH_GRBUF_SIZE, &g); 524 538 #else 525 539 g = sh_getgrgid(grp); … … 533 547 (UID_CAST)grp); 534 548 #endif 535 SL_IRETURN(SL_FALSE, _("onlytrustedingrp") ); 549 retval = SL_FALSE; 550 goto end_retval; 536 551 } 537 552 … … 544 559 /* check for untrusted members of the group 545 560 */ 561 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 562 pbuffer = malloc(SH_PWBUF_SIZE); 563 #endif 564 546 565 for(p = g->gr_mem; *p != NULL; p++) 547 566 { … … 553 572 */ 554 573 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 555 sh_getpwnam_r(*p, &pw, pbuffer, sizeof(pbuffer), &w);574 sh_getpwnam_r(*p, &pw, pbuffer, SH_PWBUF_SIZE, &w); 556 575 #else 557 576 w = sh_getpwnam(*p); … … 601 620 #endif 602 621 tf_baduid = w->pw_uid; 603 SL_IRETURN(SL_FALSE, _("onlytrustedingrp")); 604 } 605 } 622 retval = SL_FALSE; 623 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) 624 if (pbuffer) free(pbuffer); 625 #endif 626 goto end_retval; 627 } 628 } 629 630 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) 631 if (pbuffer) free(pbuffer); 632 #endif 606 633 607 634 #ifndef TEST_ONLY … … 680 707 /* all found 681 708 */ 709 end_retval: 710 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) 711 if (buffer) free(buffer); 712 #endif 682 713 SL_IRETURN(retval, _("onlytrustedingrp")); 683 714 } … … 685 716 int sl_trustfile(const char *fname, uid_t *okusers, uid_t *badusers) 686 717 { 687 char fexp[MAXFILENAME];/* file name fully expanded */688 register char *p = fexp;/* used to hold name to be checked */718 char * fexp = NULL; /* file name fully expanded */ 719 register char *p; /* used to hold name to be checked */ 689 720 struct stat stbuf; /* used to check file permissions */ 690 721 char c; /* used to hold temp char */ … … 693 724 if (fname == NULL) 694 725 SL_IRETURN(SL_EBADFILE, _("sl_trustfile")); 726 727 fexp = malloc( MAXFILENAME ); 728 if (!fexp) 729 SL_IRETURN(SL_EMEM, _("sl_trustfile")); 730 731 p = fexp; 695 732 696 733 /* … … 701 738 sl_errno = getfname(fname, fexp, MAXFILENAME); 702 739 if (sl_errno != 0) 703 return sl_errno; 740 { 741 free(fexp); 742 return sl_errno; 743 } 704 744 #else 705 745 if (SL_ISERROR(getfname(fname, fexp, MAXFILENAME))) 746 { 747 free(fexp); 706 748 SL_IRETURN(sl_errno, _("sl_trustfile")); 749 } 707 750 #endif 708 751 … … 755 798 fprintf(stderr, "---------------------------------------------\n"); 756 799 #endif 800 free(fexp); 757 801 SL_IRETURN(SL_ESTAT, _("sl_trustfile")); 758 802 } … … 781 825 * got it? 782 826 */ 783 char csym[MAXFILENAME];/* contents of symlink file */784 char full[MAXFILENAME];/* "full" name of symlink */827 char * csym; /* contents of symlink file */ 828 char * full; /* "full" name of symlink */ 785 829 register char *b, *t; /* used to copy stuff around */ 786 830 register int lsym; /* num chars in symlink ref */ … … 797 841 * R.W. Tue May 29 22:05:16 CEST 2001 798 842 */ 843 csym = malloc( MAXFILENAME ); 844 if (!csym) 845 { 846 free(fexp); 847 SL_IRETURN(SL_EMEM, _("sl_trustfile")); 848 } 849 799 850 lsym = readlink(fexp, csym, MAXFILENAME-1); 800 851 if (lsym >= 0) … … 808 859 fprintf(stderr, "---------------------------------------------\n"); 809 860 #endif 861 free(csym); 862 free(fexp); 810 863 SL_IRETURN(SL_EBADNAME, _("sl_trustfile")); 864 } 865 866 full = malloc( MAXFILENAME ); 867 if (!full) 868 { 869 free(csym); 870 free(fexp); 871 SL_IRETURN(SL_EMEM, _("sl_trustfile")); 811 872 } 812 873 … … 857 918 fprintf(stderr, "---------------------------------------------\n"); 858 919 #endif 920 free(full); 921 free(csym); 922 free(fexp); 859 923 SL_IRETURN(SL_ETRUNC, _("sl_trustfile")); 860 924 } … … 872 936 */ 873 937 if ((i = sl_trustfile(full, okusers, badusers)) != SL_ENONE) 874 SL_IRETURN(i, _("sl_trustfile")); 938 { 939 free(full); 940 free(csym); 941 free(fexp); 942 SL_IRETURN(i, _("sl_trustfile")); 943 } 875 944 876 945 /* … … 891 960 p++; 892 961 } 962 free(full); 963 free(csym); 893 964 continue; 894 965 } … … 922 993 923 994 tf_baduid = (uid_t) stbuf.st_uid; 995 free(fexp); 924 996 SL_IRETURN(SL_EBADUID, _("sl_trustfile")); 925 997 } … … 961 1033 962 1034 tf_badgid = (gid_t) stbuf.st_gid; 1035 free(fexp); 963 1036 SL_IRETURN(SL_EBADGID, _("sl_trustfile")); 964 1037 } … … 984 1057 tf_path[sizeof(tf_path)-1] = '\0'; 985 1058 1059 free(fexp); 986 1060 SL_IRETURN(SL_EBADOTH, _("sl_trustfile")); 987 1061 } … … 1009 1083 tf_path[sizeof(tf_path)-1] = '\0'; 1010 1084 1085 free(fexp); 1011 1086 SL_IRETURN(SL_ENONE, _("sl_trustfile")); 1012 1087 }
Note:
See TracChangeset
for help on using the changeset viewer.