mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
* screen.c (paint_frame): Fix possible buffer overflow.
This commit is contained in:
parent
cb4e8787ab
commit
03976121d9
@ -1,3 +1,7 @@
|
||||
2004-08-19 Pavel Shirshov <pavelsh@mail.ru>
|
||||
|
||||
* screen.c (paint_frame): Fix possible buffer overflow.
|
||||
|
||||
2004-08-18 Pavel Shirshov <pavelsh@mail.ru>
|
||||
|
||||
* background.c (do_background): Use O_RDWR when opening
|
||||
|
14
src/screen.c
14
src/screen.c
@ -1060,7 +1060,7 @@ paint_frame (WPanel *panel)
|
||||
int spaces, extra;
|
||||
int side, width;
|
||||
|
||||
char *txt, buffer[30]; /*Hope that this is enough ;-) */
|
||||
char *txt;
|
||||
if (!panel->split)
|
||||
adjust_top_file (panel);
|
||||
|
||||
@ -1086,18 +1086,14 @@ paint_frame (WPanel *panel)
|
||||
txt = format->title;
|
||||
|
||||
header_len = strlen (txt);
|
||||
if (header_len > format->field_len){
|
||||
strcpy (buffer, txt);
|
||||
txt = buffer;
|
||||
txt [format->field_len] = 0;
|
||||
header_len = strlen (txt);
|
||||
}
|
||||
if (header_len > format->field_len)
|
||||
header_len = format->field_len;
|
||||
|
||||
attrset (MARKED_COLOR);
|
||||
spaces = (format->field_len - header_len) / 2;
|
||||
extra = (format->field_len - header_len) % 2;
|
||||
printw ("%*s%-s%*s", spaces, "",
|
||||
txt, spaces+extra, "");
|
||||
printw ("%*s%.*s%*s", spaces, "",
|
||||
header_len, txt, spaces+extra, "");
|
||||
width -= 2 * spaces + extra + header_len;
|
||||
} else {
|
||||
attrset (NORMAL_COLOR);
|
||||
|
Loading…
Reference in New Issue
Block a user