[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master cb9f299 1/2: Fix buffer overrun in src/imgcrop
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master cb9f299 1/2: Fix buffer overrun in src/imgcrop/imgcrop.c |
Date: |
Wed, 3 Aug 2016 23:45:03 +0000 (UTC) |
branch: master
commit cb9f29965e91a66b951a9c8394f0c8229d1f2f90
Author: Vladimir Markelov <address@hidden>
Commit: Vladimir Markelov <address@hidden>
Fix buffer overrun in src/imgcrop/imgcrop.c
The code logs a lines of predefined lenght, and the lenght is not too
long. So, a long file names overrun the buffer for a log line and make
the application crash. The fix truncs a long file names upto 30
characters before writing to the log.
This fixed the bugs 46241 and 45380
---
src/imgcrop/imgcrop.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/imgcrop/imgcrop.c b/src/imgcrop/imgcrop.c
index cd123ba..7094168 100644
--- a/src/imgcrop/imgcrop.c
+++ b/src/imgcrop/imgcrop.c
@@ -49,7 +49,7 @@ imgmodecrop(void *inparam)
struct imgcropparams *p=crp->p;
struct gal_commonparams *cp=&p->cp;
- size_t i;
+ size_t i, job_len;
int status;
struct inputimgs *img;
struct imgcroplog *log;
@@ -104,8 +104,13 @@ imgmodecrop(void *inparam)
on the terminal, if the user askd for it. */
if(cp->verb)
{
- sprintf(msg, "%-30s %lu %d", log->name, log->numimg,
- log->centerfilled);
+ job_len = strlen(log->name);
+ if (job_len > 30)
+ sprintf(msg, "...%s %lu %d", &log->name[job_len-27], log->numimg,
+ log->centerfilled);
+ else
+ sprintf(msg, "%-30s %lu %d", log->name, log->numimg,
+ log->centerfilled);
gal_timing_report(NULL, msg, 2);
}
}