aboutsummaryrefslogtreecommitdiffstats
path: root/com32/hdt
diff options
context:
space:
mode:
authorErwan Velu <erwanaliasr1@gmail.com>2011-03-22 23:02:55 +0100
committerErwan Velu <erwanaliasr1@gmail.com>2011-03-22 23:02:55 +0100
commitbaac23fcbb985b10ad2c06dd33d3e07835d7f0b5 (patch)
tree94449435d304a7848e4c3d7a6c2a8764da46423d /com32/hdt
parent7561c21cdc63e78d1ac700c43e25fcaea40e0575 (diff)
downloadsyslinux-baac23fcbb985b10ad2c06dd33d3e07835d7f0b5.tar.gz
syslinux-baac23fcbb985b10ad2c06dd33d3e07835d7f0b5.tar.xz
syslinux-baac23fcbb985b10ad2c06dd33d3e07835d7f0b5.zip
hdt: Fixing memory corruption
When flusing the output, we need to reset also len & size.
Diffstat (limited to 'com32/hdt')
-rw-r--r--com32/hdt/hdt-dump.c15
-rw-r--r--com32/hdt/hdt-dump.h3
2 files changed, 8 insertions, 10 deletions
diff --git a/com32/hdt/hdt-dump.c b/com32/hdt/hdt-dump.c
index 324fd81a..429902d6 100644
--- a/com32/hdt/hdt-dump.c
+++ b/com32/hdt/hdt-dump.c
@@ -59,11 +59,6 @@ void compute_filename(struct s_hardware *hardware, char *filename, int size) {
}
-void print_and_flush(ZZJSON_CONFIG *config, ZZJSON **item) {
- zzjson_print(config, *item);
- zzjson_free(config, *item);
-}
-
int dumpprintf(FILE *p, const char *format, ...) {
va_list ap;
int rv;
@@ -76,12 +71,15 @@ int dumpprintf(FILE *p, const char *format, ...) {
}
void flush (char *filename, ZZJSON_CONFIG *config, ZZJSON ** item) {
- print_and_flush(config,item);
+ zzjson_print(config, *item);
cpio_writefile(upload,filename,p_buf.buf,p_buf.len);
- if (p_buf.buf) {
+ if ((p_buf.buf) && (p_buf.size > 0)){
memset(p_buf.buf,0,p_buf.size);
free(p_buf.buf);
+ p_buf.size=0;
+ p_buf.len=0;
}
+ zzjson_free(config, *item);
}
/**
@@ -99,8 +97,6 @@ void dump(struct s_hardware *hardware)
(int(*)(int,void*)) fputc
};
- detect_hardware(hardware);
-
/* By now, we only support TFTP reporting */
upload=&upload_tftp;
upload->name="tftp";
@@ -120,6 +116,7 @@ void dump(struct s_hardware *hardware)
dump_cpu(hardware, &config, &json);
dump_pxe(hardware, &config, &json);
+ dump_syslinux(hardware, &config, &json);
/* We close & flush the file to send */
cpio_close(upload);
diff --git a/com32/hdt/hdt-dump.h b/com32/hdt/hdt-dump.h
index 933d5436..0f1f8173 100644
--- a/com32/hdt/hdt-dump.h
+++ b/com32/hdt/hdt-dump.h
@@ -39,7 +39,7 @@
#define add_bool_true(name) *item = zzjson_object_append(config, *item, name, zzjson_create_true(config))
#define add_bool_false(name) *item = zzjson_object_append(config, *item, name, zzjson_create_false(config))
#define add_hi(value) add_i(#value,hardware->value)
-#define add_hs(value) add_s(#value,hardware->value)
+#define add_hs(value) add_s(#value,(char *)hardware->value)
#define add_b(name,value) if (value==true) {add_bool_true((char *)name);} else {add_bool_false((char *)name);}
extern struct print_buf p_buf;
@@ -50,3 +50,4 @@ void flush (char *filename, ZZJSON_CONFIG *config, ZZJSON ** item);
void dump_cpu(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item);
void dump_pxe(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item);
+void dump_syslinux(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item);