[Pdbg] [PATCH] putmem: Fix Floating point exception issue
Vasant Hegde
hegdevasant at linux.vnet.ibm.com
Fri Jul 6 00:41:15 AEST 2018
Validate read() before calling __adu_putmem().
Also check end size in progress_tick().
Signed-off-by: Vasant Hegde <hegdevasant at linux.vnet.ibm.com>
---
src/mem.c | 3 +++
src/progress.c | 3 +++
2 files changed, 6 insertions(+)
diff --git a/src/mem.c b/src/mem.c
index b2ab917..4b2c829 100644
--- a/src/mem.c
+++ b/src/mem.c
@@ -90,6 +90,9 @@ static int putmem(uint64_t addr, struct mem_flags flags)
progress_init();
do {
read_size = read(STDIN_FILENO, buf, PUTMEM_BUF_SIZE);
+ if (read_size <= 0)
+ break;
+
if (__adu_putmem(adu_target, addr, buf, read_size, flags.ci)) {
rc = 0;
printf("Unable to write memory.\n");
diff --git a/src/progress.c b/src/progress.c
index fe443b9..e57b8de 100644
--- a/src/progress.c
+++ b/src/progress.c
@@ -51,6 +51,9 @@ void progress_tick(uint64_t cur, uint64_t end)
uint64_t pcent;
double sec;
+ if (end == 0)
+ return;
+
pcent = (cur * 100) / end;
if (progress_pcent == pcent && cur < progress_n_upd &&
cur < end)
--
2.14.3
More information about the Pdbg
mailing list