Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:michals
hexedit
hexedit-Prevent-division-by-zero-on-empty-files...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File hexedit-Prevent-division-by-zero-on-empty-files.patch of Package hexedit
From 41981645134d201151f1cea9fd964d892166e866 Mon Sep 17 00:00:00 2001 From: Tobias Stoeckmann <tobias@stoeckmann.org> Date: Sun, 4 Oct 2020 20:18:00 +0200 Subject: [PATCH] Prevent division by zero on empty files. Git-commit: 41981645134d201151f1cea9fd964d892166e866 Upstream: accepted (expected in 1.15.1) Hexedit crashes with a floating point exception when an empty file is opened. This was introduced with percentage view in status line and released with version 1.5. How to reproduce: $ touch empty $ hexedit empty --- display.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/display.c b/display.c index 9b4df91..a012b27 100644 --- a/display.c +++ b/display.c @@ -182,6 +182,7 @@ void exitCurses(void) void display(void) { + long long fsize; int i; for (i = 0; i < nbBytes; i += lineLength) { @@ -204,8 +205,9 @@ void display(void) else if (edited) i = '*'; else i = '-'; printw("-%c%c %s --0x%llX", i, i, baseName, (long long) base + cursor); - if (MAX(fileSize, lastEditedLoc)) printw("/0x%llX", (long long) getfilesize()); - printw("--%i%%", 100 * (base + cursor + getfilesize()/200) / getfilesize() ); + fsize = getfilesize(); + if (MAX(fileSize, lastEditedLoc)) printw("/0x%llX", fsize); + printw("--%i%%", fsize == 0 ? 0 : 100 * (base + cursor + fsize/200) / fsize ); if (mode == bySector) printw("--sector %lld", (long long) ((base + cursor) / SECTOR_SIZE)); move(cursor / lineLength, computeCursorXCurrentPos()); -- 2.29.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor