- Timestamp:
- Jun 29, 2021, 10:23:44 PM (3 years ago)
- Location:
- trunk/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/dnmalloc.c
r520 r562 165 165 * HAVE_SYS_PARAM_H Define to #include <sys/param.h> (for pagesize) 166 166 * 167 * HAVE_MALLOC_H Define to #include <malloc.h> (for struct mallinfo )167 * HAVE_MALLOC_H Define to #include <malloc.h> (for struct mallinfo2) 168 168 * 169 169 * HAVE_FCNTL_H Define to #include <fcntl.h> … … 531 531 #define vALLOc public_vALLOc 532 532 #define pVALLOc public_pVALLOc 533 #define mALLINFo public_mALLINFo533 #define mALLINFo2 public_mALLINFo2 534 534 #define mALLOPt public_mALLOPt 535 535 #define mTRIm public_mTRIm … … 547 547 #define public_vALLOc dlvalloc 548 548 #define public_pVALLOc dlpvalloc 549 #define public_mALLINFo dlmallinfo549 #define public_mALLINFo2 dlmallinfo2 550 550 #define public_mALLOPt dlmallopt 551 551 #define public_mTRIm dlmalloc_trim … … 561 561 #define public_vALLOc valloc 562 562 #define public_pVALLOc pvalloc 563 #define public_mALLINFo mallinfo563 #define public_mALLINFo2 mallinfo2 564 564 #define public_mALLOPt mallopt 565 565 #define public_mTRIm malloc_trim … … 791 791 792 792 /* 793 This version of malloc supports the standard SVID/XPG mallinfo 793 This version of malloc supports the standard SVID/XPG mallinfo2 794 794 routine that returns a struct containing usage properties and 795 795 statistics. It should work on any SVID/XPG compliant system that has 796 a /usr/include/malloc.h defining struct mallinfo . (If you'd like to796 a /usr/include/malloc.h defining struct mallinfo2. (If you'd like to 797 797 install such a thing yourself, cut out the preliminary declarations 798 798 as described above and below and save them in a malloc.h file. But 799 799 there's no compelling reason to bother to do this.) 800 800 801 The main declaration needed is the mallinfo struct that is returned802 (by-copy) by mallinfo (). The SVID/XPG malloinfostruct contains a801 The main declaration needed is the mallinfo2 struct that is returned 802 (by-copy) by mallinfo2(). The SVID/XPG malloinfo2 struct contains a 803 803 bunch of fields that are not even meaningful in this version of 804 malloc. These fields are are instead filled by mallinfo () with804 malloc. These fields are are instead filled by mallinfo2() with 805 805 other numbers that might be of interest. 806 806 807 807 HAVE_MALLOC_H should be set if you have a 808 808 /usr/include/malloc.h file that includes a declaration of struct 809 mallinfo . If so, it is included; else an SVID2/XPG2 compliant809 mallinfo2. If so, it is included; else an SVID2/XPG2 compliant 810 810 version is declared below. These must be precisely the same for 811 mallinfo () to work. The original SVID version of this struct,812 defined on most systems with mallinfo , declares all fields as813 ints. But some others define as unsigned long. If your system811 mallinfo2() to work. The original SVID version of this struct, 812 defined on most systems with mallinfo2, declares all fields as 813 size_2. But some others define as unsigned long. If your system 814 814 defines the fields using a type of different width than listed here, 815 815 you must #include your system version and #define … … 826 826 #else 827 827 828 /* SVID2/XPG mallinfo structure */829 830 struct mallinfo {831 int arena; /* non-mmapped space allocated from system */832 int ordblks; /* number of free chunks */833 int smblks; /* number of fastbin blocks */834 int hblks; /* number of mmapped regions */835 int hblkhd; /* space in mmapped regions */836 int usmblks; /* maximum total allocated space */837 int fsmblks; /* space available in freed fastbin blocks */838 int uordblks; /* total allocated space */839 int fordblks; /* total free space */840 int keepcost; /* top-most, releasable (via malloc_trim) space */828 /* SVID2/XPG mallinfo2 structure */ 829 830 struct mallinfo2 { 831 size_t arena; /* non-mmapped space allocated from system */ 832 size_t ordblks; /* number of free chunks */ 833 size_t smblks; /* number of fastbin blocks */ 834 size_t hblks; /* number of mmapped regions */ 835 size_t hblkhd; /* space in mmapped regions */ 836 size_t usmblks; /* maximum total allocated space */ 837 size_t fsmblks; /* space available in freed fastbin blocks */ 838 size_t uordblks; /* total allocated space */ 839 size_t fordblks; /* total free space */ 840 size_t keepcost; /* top-most, releasable (via malloc_trim) space */ 841 841 }; 842 842 … … 1008 1008 1009 1009 /* 1010 mallinfo ()1010 mallinfo2() 1011 1011 Returns (by copy) a struct containing various summary statistics: 1012 1012 … … 1031 1031 */ 1032 1032 #if __STD_C 1033 struct mallinfo public_mALLINFo(void);1034 #else 1035 struct mallinfo public_mALLINFo();1033 struct mallinfo2 public_mALLINFo2(void); 1034 #else 1035 struct mallinfo2 public_mALLINFo2(); 1036 1036 #endif 1037 1037 … … 1115 1115 1116 1116 malloc_stats prints only the most commonly interesting statistics. 1117 More information can be obtained by calling mallinfo .1117 More information can be obtained by calling mallinfo2. 1118 1118 1119 1119 */ … … 1366 1366 static void mSTATs(); 1367 1367 static int mALLOPt(int, int); 1368 static struct mallinfo mALLINFo(void);1368 static struct mallinfo2 mALLINFo2(void); 1369 1369 #else 1370 1370 static Void_t* mALLOc(); … … 1380 1380 static void mSTATs(); 1381 1381 static int mALLOPt(); 1382 static struct mallinfo mALLINFo();1382 static struct mallinfo2 mALLINFo2(); 1383 1383 #endif 1384 1384 … … 1687 1687 } 1688 1688 1689 struct mallinfo public_mALLINFo() {1690 struct mallinfo m;1689 struct mallinfo2 public_mALLINFo2() { 1690 struct mallinfo2 m; 1691 1691 if (MALLOC_PREACTION == 0) { 1692 m = mALLINFo ();1692 m = mALLINFo2(); 1693 1693 (void) MALLOC_POSTACTION; 1694 1694 return m; 1695 1695 } else { 1696 struct mallinfo nm = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };1696 struct mallinfo2 nm = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1697 1697 return nm; 1698 1698 } … … 5293 5293 */ 5294 5294 5295 DL_STATIC struct mallinfo mALLINFo()5295 DL_STATIC struct mallinfo2 mALLINFo2() 5296 5296 { 5297 5297 mstate av = get_malloc_state(); 5298 static struct mallinfo mi;5298 static struct mallinfo2 mi; 5299 5299 unsigned int i; 5300 5300 mbinptr b; … … 5361 5361 DL_STATIC void mSTATs() 5362 5362 { 5363 struct mallinfo mi = mALLINFo();5363 struct mallinfo2 mi = mALLINFo2(); 5364 5364 5365 5365 fprintf(stderr, "hashtable = %10lu MB\n", -
trunk/src/sh_login_track.c
r541 r562 402 402 while(u) 403 403 { 404 if (0 == s trcmp(user, u->user))404 if (0 == sl_strcmp(user, u->user)) 405 405 { 406 406 return u; … … 839 839 else 840 840 { 841 q = strchr(host, '.'); 841 char * tmp = sh_util_strdup(host); 842 q = strchr(tmp, '.'); 842 843 if (q && *q) 843 844 { 844 845 ++q; 845 846 p = sh_util_strdup(q); 847 SH_FREE(tmp); 846 848 } 847 849 else 848 850 { 849 p = sh_util_strdup(host);851 p = tmp; 850 852 } 851 853 } -
trunk/src/sh_tools.c
r550 r562 1386 1386 } 1387 1387 1388 #ifdef SH_ENCRYPT 1388 1389 static int probe_ok(int flag) 1389 1390 { … … 1393 1394 return S_FALSE; 1394 1395 } 1396 #endif 1395 1397 1396 1398 static unsigned char probe_header_set(unsigned char protocol) … … 1444 1446 } 1445 1447 1448 #ifdef SH_ENCRYPT 1446 1449 static int probe_ok(int flag) 1447 1450 { … … 1450 1453 return S_FALSE; 1451 1454 } 1455 #endif 1456 1452 1457 #endif 1453 1458 -
trunk/src/t-test0.c
r541 r562 390 390 actions = RANDOM(&ld, ACTIONS_MAX); 391 391 #if USE_MALLOC && MALLOC_DEBUG 392 if(actions < 2) { mallinfo (); }392 if(actions < 2) { mallinfo2(); } 393 393 #endif 394 394 for(j=0; j<actions; j++) { -
trunk/src/t-test1.c
r481 r562 499 499 actions = RANDOM(&ld, ACTIONS_MAX); 500 500 #if USE_MALLOC && MALLOC_DEBUG 501 if(actions < 2) { mallinfo (); }501 if(actions < 2) { mallinfo2(); } 502 502 #endif 503 503 for(j=0; j<actions; j++) { -
trunk/src/yulectl.c
r481 r562 48 48 #endif 49 49 50 #define SH_PW_SIZE 15 51 50 52 static int sock = -1; 51 static char password[ 15] = "";53 static char password[SH_PW_SIZE] = ""; 52 54 static int verbose = 0; 53 55 … … 123 125 static char * safe_copy(char * to, const char * from, size_t size) 124 126 { 125 if (to && from) 126 { 127 strncpy (to, from, size); 128 if (size > 0) 129 to[size-1] = '\0'; 130 else 131 *to = '\0'; 127 if (to && from && (size > 0)) 128 { 129 strncpy (to, from, size-1); 130 to[size-1] = '\0'; 132 131 } 133 132 return to; … … 144 143 */ 145 144 name.sun_family = AF_UNIX; 146 strncpy (name.sun_path, serversock, sizeof(name.sun_path) - 1); 145 memcpy(name.sun_path, serversock, sizeof(name.sun_path)); 146 name.sun_path[sizeof(name.sun_path)-1] = '\0'; 147 if (strlen(serversock) > strlen(name.sun_path)) 148 { 149 perror (_("ERROR: socket path too long")); 150 return -1; 151 } 147 152 size = (offsetof (struct sockaddr_un, sun_path) 148 153 + strlen (name.sun_path) + 1); … … 401 406 */ 402 407 pw = getenv(_("YULECTL_PASSWORD")); 403 if (pw && strlen(pw) < 15)408 if (pw && strlen(pw) < SH_PW_SIZE) 404 409 { 405 410 strcpy(password, pw); … … 413 418 return -1; 414 419 415 if ( (strlen(home) + strlen(_("/.yulectl_cred")) + 1) > 4096)420 if ( (strlen(home) + strlen(_("/.yulectl_cred")) + 1) > sizeof(home)) 416 421 { 417 422 fprintf (stderr, "%s", _("ERROR: path for $HOME is too long.\n")); … … 451 456 (void) rtrim(message2); 452 457 453 if (strlen(message2) > 14)458 if (strlen(message2) > (SH_PW_SIZE -1)) 454 459 { 455 460 fprintf (stderr, "%s",
Note:
See TracChangeset
for help on using the changeset viewer.