aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/k12text.l
diff options
context:
space:
mode:
authorAnders Broman <anders.broman@ericsson.com>2008-05-13 19:05:03 +0000
committerAnders Broman <anders.broman@ericsson.com>2008-05-13 19:05:03 +0000
commitbf75c5fed27bb812a5309cc9ad04d85a28d69dc7 (patch)
treea3cbe45e5aaed3ee5d1892f61580230c0a882270 /wiretap/k12text.l
parent547cda2f1f5023da469f841f34bd86a7ec33c4f5 (diff)
From: Luis Ontanon
Fix errors from checkapi. svn path=/trunk/; revision=25287
Diffstat (limited to 'wiretap/k12text.l')
-rw-r--r--wiretap/k12text.l29
1 files changed, 19 insertions, 10 deletions
diff --git a/wiretap/k12text.l b/wiretap/k12text.l
index d832d6b588..1c440176df 100644
--- a/wiretap/k12text.l
+++ b/wiretap/k12text.l
@@ -259,6 +259,8 @@ static gboolean k12text_dump(wtap_dumper *wdh _U_, const struct wtap_pkthdr *phd
const union wtap_pseudo_header *pseudo_header _U_,
const guchar *pd, int *err _U_) {
char buf[196808];
+ size_t left = 196808;
+ gint wl;
char* p=buf;
const char* str_enc = "";
guint i;
@@ -274,17 +276,24 @@ static gboolean k12text_dump(wtap_dumper *wdh _U_, const struct wtap_pkthdr *phd
}
strftime(p,90,"+---------+---------------+----------+\r\n%H:%M:%S,",gmtime(&phdr->ts.secs));
- p+= strlen(p);
- sprintf(p,"%.3d,%.3d %s\r\n|0 |",ms,ns,str_enc);
- p+= strlen(p);
-
- for(i=0;i < phdr->caplen; i++) {
- sprintf(p,"%.2x|",pd[i]);
- p+= 3;
- }
-
- sprintf(p,"\r\n\r\n");
+ wl = strlen(p);
+ p += wl;
+ left -= wl;
+
+ wl = g_snprintf(p,left,"%.3d,%.3d %s\r\n|0 |",ms,ns,str_enc);
+ p+= wl;
+ left -= wl;
+
+ for(i=0;i < phdr->caplen && left > 2; i++) {
+ wl = g_snprintf(p,left,"%.2x|",pd[i]);
+ p += wl;
+ left -= wl;
+ }
+ wl = g_snprintf(p,left,"\r\n\r\n");
+ p+= wl;
+ left -= wl;
+
fwrite(buf, 1, strlen(buf), wdh->fh);
return TRUE;