mirror of https://github.com/MidnightCommander/mc
Revert "Ticket #3666: (size_trunc_len): fix segfault because of small buffer usage."
This reverts commit 3024f309c2
.
This commit is contained in:
parent
7374b9c626
commit
e3d457eb3d
10
lib/util.c
10
lib/util.c
|
@ -402,10 +402,10 @@ size_trunc_sep (uintmax_t size, gboolean use_si)
|
|||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Print file SIZE to BUFFER, but don't exceed LEN characters, not including trailing 0.
|
||||
* LEN should be at least 7 long and BUFFER at least LEN+1 long.
|
||||
*
|
||||
* This function is called for every file on panels, so avoid floating point by any means.
|
||||
* Print file SIZE to BUFFER, but don't exceed LEN characters,
|
||||
* not including trailing 0. BUFFER should be at least LEN+1 long.
|
||||
* This function is called for every file on panels, so avoid
|
||||
* floating point by any means.
|
||||
*
|
||||
* Units: size units (filesystem sizes are 1K blocks)
|
||||
* 0=bytes, 1=Kbytes, 2=Mbytes, etc.
|
||||
|
@ -458,8 +458,6 @@ size_trunc_len (char *buffer, unsigned int len, uintmax_t size, int units, gbool
|
|||
const char *const *sfx = use_si ? units_si : units_iec;
|
||||
int j = 0;
|
||||
|
||||
g_assert (len >= 7);
|
||||
|
||||
if (len == 0)
|
||||
len = 9;
|
||||
#if SIZEOF_UINTMAX_T == 8
|
||||
|
|
|
@ -147,8 +147,7 @@ const char *size_trunc (uintmax_t size, gboolean use_si);
|
|||
const char *size_trunc_sep (uintmax_t size, gboolean use_si);
|
||||
|
||||
/* Print file SIZE to BUFFER, but don't exceed LEN characters,
|
||||
* not including trailing 0. LEN should be at least 7 long
|
||||
* and BUFFER at least LEN+1 long.
|
||||
* not including trailing 0. BUFFER should be at least LEN+1 long.
|
||||
*
|
||||
* Units: size units (0=bytes, 1=Kbytes, 2=Mbytes, etc.) */
|
||||
void size_trunc_len (char *buffer, unsigned int len, uintmax_t size, int units, gboolean use_si);
|
||||
|
|
|
@ -56,6 +56,8 @@
|
|||
|
||||
/*** file scope macro definitions ****************************************************************/
|
||||
|
||||
#define BUF_TRUNC_LEN 5 /* The length of the line displays the file size */
|
||||
|
||||
/*** file scope type declarations ****************************************************************/
|
||||
|
||||
/*** file scope variables ************************************************************************/
|
||||
|
@ -170,9 +172,9 @@ mcview_display_status (WView * view)
|
|||
tty_printf ("0x%08" PRIxMAX, (uintmax_t) view->hex_cursor);
|
||||
else
|
||||
{
|
||||
char buffer[12];
|
||||
char buffer[BUF_TRUNC_LEN + 1];
|
||||
|
||||
size_trunc_len (buffer, sizeof (buffer) - 1, mcview_get_filesize (view), 0,
|
||||
size_trunc_len (buffer, BUF_TRUNC_LEN, mcview_get_filesize (view), 0,
|
||||
panels_options.kilobyte_si);
|
||||
tty_printf ("%9" PRIuMAX "/%s%s %s", (uintmax_t) view->dpy_end,
|
||||
buffer, mcview_may_still_grow (view) ? "+" : " ",
|
||||
|
|
Loading…
Reference in New Issue