Rewrote to use g_strlcpy and g_strlcat.

svn path=/trunk/; revision=24531
This commit is contained in:
Stig Bjørlykke 2008-03-02 21:12:24 +00:00
parent 280d579242
commit f6026eb978
3 changed files with 7 additions and 6 deletions

View File

@ -37,6 +37,7 @@
#include "epan/packet_info.h"
#include <epan/tap.h>
#include <epan/stat_cmd_args.h>
#include <epan/strutil.h>
#include "register.h"
@ -667,8 +668,7 @@ iostat_init(const char *optarg, void* userdata _U_)
register_io_tap(io, i, tmp);
} else {
tmp=g_malloc((pos-str)+1);
strncpy(tmp,str,(pos-str));
tmp[pos-str]=0;
g_strlcpy(tmp,str,(pos-str)+1);
register_io_tap(io, i, tmp);
}
str=pos+1;

View File

@ -40,6 +40,7 @@
#include "epan/proto.h"
#include <epan/tap.h>
#include <epan/stat_cmd_args.h>
#include <epan/strutil.h>
#include "register.h"
typedef struct _pci_t {
@ -117,8 +118,7 @@ protocolinfo_init(const char *optarg, void* userdata _U_)
rs->hf_index=hfi->id;
if((field-filter)>1){
rs->filter=g_malloc(field-filter);
strncpy(rs->filter,filter,(field-filter)-1);
rs->filter[(field-filter)-1]=0;
g_strlcpy(rs->filter,filter,(field-filter));
} else {
rs->filter=NULL;
}

5
util.c
View File

@ -40,6 +40,7 @@
#include <epan/address.h>
#include <epan/addr_resolv.h>
#include <epan/ws_strsplit.h>
#include <epan/strutil.h>
#include "util.h"
@ -78,11 +79,11 @@ get_args_as_string(int argc, char **argv, int optind)
argstring[0] = '\0';
i = optind;
for (;;) {
strncat(argstring, argv[i], len - strlen(argstring));
g_strlcat(argstring, argv[i], len);
i++;
if (i == argc)
break;
strncat(argstring, " ", len - strlen(argstring));
g_strlcat(argstring, " ", len);
}
return argstring;
}