From 9ca3c9cc9eeb578b60c4d27746dc4e7447face0c Mon Sep 17 00:00:00 2001 From: Erwan Velu Date: Sun, 3 Apr 2011 20:57:51 +0200 Subject: [PATCH] hdt: Removing corruption on printf Prior to this commit some garbage occured. The printing buffer wasn't correctly cleaned after usage. --- com32/hdt/hdt-dump.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/com32/hdt/hdt-dump.c b/com32/hdt/hdt-dump.c index 9b0fe7b..c09568c 100644 --- a/com32/hdt/hdt-dump.c +++ b/com32/hdt/hdt-dump.c @@ -70,16 +70,21 @@ int dumpprintf(FILE *p, const char *format, ...) { return rv; } -void flush (char *filename, ZZJSON_CONFIG *config, ZZJSON ** item) { - zzjson_print(config, *item); +void to_cpio(char *filename) { cpio_writefile(upload,filename,p_buf.buf,p_buf.len); - if ((p_buf.buf) && (p_buf.size > 0)){ - memset(p_buf.buf,0,p_buf.size); + if ((p_buf.buf) && (p_buf.len > 0)){ + memset(p_buf.buf,0,p_buf.len); free(p_buf.buf); + p_buf.buf=NULL; p_buf.size=0; p_buf.len=0; } +} + +void flush (ZZJSON_CONFIG *config, ZZJSON ** item) { + zzjson_print(config, *item); zzjson_free(config, *item); + *item=NULL; } /** @@ -97,6 +102,8 @@ void dump(struct s_hardware *hardware) (int(*)(int,void*)) fputc }; + memset(&p_buf,0,sizeof(p_buf)); + /* By now, we only support TFTP reporting */ upload=&upload_tftp; upload->name="tftp"; -- 2.7.4