Changeset 47d4f8c
- Timestamp:
- 06/27/18 18:01:48 (3 years ago)
- Branches:
- cachetimestamps, develop, master, rc-4.0.4, ringdecrementfix, ringperformance
- Children:
- 1ed69dc
- Parents:
- 35de364
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/format_linux_common.c
rf9df20e r47d4f8c 87 87 sock = socket(PF_INET, SOCK_STREAM, 0); 88 88 memset(&ifr, 0, sizeof(struct ifreq)); 89 strncpy(ifr.ifr_name, libtrace->uridata, IF_NAMESIZE );89 strncpy(ifr.ifr_name, libtrace->uridata, IF_NAMESIZE - 1); 90 90 if (ioctl(sock, SIOCGIFHWADDR, &ifr) != 0) { 91 91 perror("Can't get HWADDR for interface"); -
lib/libtrace.h.in
r32ee9b2 r47d4f8c 277 277 typedef struct trace_err_t{ 278 278 int err_num; /**< error code */ 279 char problem[ 255]; /**< the format, uri etc that caused the error for reporting purposes */279 char problem[1024]; /**< the format, uri etc that caused the error for reporting purposes */ 280 280 } libtrace_err_t; 281 281 -
lib/trace.c
r32ee9b2 r47d4f8c 107 107 * will use our own one that does 108 108 */ 109 static void xstrncpy(char *dest, const char *src, size_t n) 110 { 111 strncpy(dest,src,n); 112 dest[n]='\0'; 109 static inline void xstrncpy(char *dest, const char *src, size_t n, 110 size_t destlen) 111 { 112 size_t slen = destlen - 1; 113 if (n < slen) { 114 slen = n; 115 } 116 strncpy(dest,src,slen); 117 dest[slen]='\0'; 113 118 } 114 119 … … 120 125 exit(EXIT_FAILURE); 121 126 } 122 xstrncpy(ret,src,n );127 xstrncpy(ret,src,n,n+1); 123 128 return ret; 124 129 } … … 371 376 372 377 if((uridata = strchr(uri,':')) == NULL) { 373 xstrncpy(scan, uri, strlen(uri) );378 xstrncpy(scan, uri, strlen(uri), URI_PROTO_LINE); 374 379 } else { 375 xstrncpy(scan,uri, (size_t)(uridata - uri) );380 xstrncpy(scan,uri, (size_t)(uridata - uri), URI_PROTO_LINE); 376 381 } 377 382 -
libpacketdump/eth_2054.c
ree6e802 r47d4f8c 47 47 static char *format_hrd(const struct arphdr *arp, const char *hrd) { 48 48 static char buffer[1024] = {0,}; 49 int i; 49 int i, ret; 50 size_t bufused; 50 51 51 52 if (!hrd) { … … 59 60 break; 60 61 default: 62 bufused = 0; 61 63 for (i=0;i<arp->ar_hln;i++) { 62 snprintf(buffer,sizeof(buffer),"%s %02x", 63 buffer,(unsigned char)hrd[i]); 64 if (bufused >= sizeof(buffer)) { 65 break; 66 } 67 ret = snprintf(buffer + bufused, 68 sizeof(buffer) - bufused, 69 "%02x ", 70 (unsigned char)hrd[i]); 71 if (ret > 0) { 72 bufused += ret; 73 } 64 74 } 65 75 break; … … 77 87 static char *format_pro(const struct arphdr *arp, const char *pro) { 78 88 static char buffer[1024] = {0,}; 79 int i; 89 int i, ret; 90 size_t bufused; 80 91 81 92 if (!pro) { … … 91 102 default: 92 103 snprintf(buffer, sizeof(buffer), "%s", " ("); 104 bufused = 2; 93 105 for (i=0;i<arp->ar_pln;i++) { 94 snprintf(buffer,sizeof(buffer),"%s %02x", 95 buffer,(unsigned char)pro[i]); 106 if (bufused >= sizeof(buffer)) { 107 break; 108 } 109 ret = snprintf(buffer + bufused, 110 sizeof(buffer) - bufused, 111 "%02x ", 112 (unsigned char)pro[i]); 113 if (ret > 0) { 114 bufused += ret; 115 } 96 116 } 97 strncat(buffer,")",sizeof(buffer) - strlen(buffer) - 1); 117 if (bufused < sizeof(buffer)) { 118 snprintf(buffer + bufused, 119 sizeof(buffer) - bufused, 120 ")"); 121 } 98 122 break; 99 123 } -
tools/tracereport/misc_report.c
r8e11beb r47d4f8c 67 67 { 68 68 static char ret[1024]; 69 char tmp[1 024];69 char tmp[128]; 70 70 ret[0]='\0'; 71 71 if (ts == 0) -
tools/tracesplit/tracesplit.c
r92cf299 r47d4f8c 61 61 static char *strdupcat(char *str,char *app) 62 62 { 63 str=realloc(str,strlen(str)+strlen(app)+1); 64 strncat(str,app,strlen(str) + strlen(app)); 63 int newsize = strlen(str)+strlen(app)+1; 64 str=realloc(str,newsize); 65 strncat(str,app,newsize - strlen(str) - 1); 65 66 return str; 66 67 }
Note: See TracChangeset
for help on using the changeset viewer.