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>
|
2004-08-18 Pavel Shirshov <pavelsh@mail.ru>
|
||||||
|
|
||||||
* background.c (do_background): Use O_RDWR when opening
|
* 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 spaces, extra;
|
||||||
int side, width;
|
int side, width;
|
||||||
|
|
||||||
char *txt, buffer[30]; /*Hope that this is enough ;-) */
|
char *txt;
|
||||||
if (!panel->split)
|
if (!panel->split)
|
||||||
adjust_top_file (panel);
|
adjust_top_file (panel);
|
||||||
|
|
||||||
@ -1086,18 +1086,14 @@ paint_frame (WPanel *panel)
|
|||||||
txt = format->title;
|
txt = format->title;
|
||||||
|
|
||||||
header_len = strlen (txt);
|
header_len = strlen (txt);
|
||||||
if (header_len > format->field_len){
|
if (header_len > format->field_len)
|
||||||
strcpy (buffer, txt);
|
header_len = format->field_len;
|
||||||
txt = buffer;
|
|
||||||
txt [format->field_len] = 0;
|
|
||||||
header_len = strlen (txt);
|
|
||||||
}
|
|
||||||
|
|
||||||
attrset (MARKED_COLOR);
|
attrset (MARKED_COLOR);
|
||||||
spaces = (format->field_len - header_len) / 2;
|
spaces = (format->field_len - header_len) / 2;
|
||||||
extra = (format->field_len - header_len) % 2;
|
extra = (format->field_len - header_len) % 2;
|
||||||
printw ("%*s%-s%*s", spaces, "",
|
printw ("%*s%.*s%*s", spaces, "",
|
||||||
txt, spaces+extra, "");
|
header_len, txt, spaces+extra, "");
|
||||||
width -= 2 * spaces + extra + header_len;
|
width -= 2 * spaces + extra + header_len;
|
||||||
} else {
|
} else {
|
||||||
attrset (NORMAL_COLOR);
|
attrset (NORMAL_COLOR);
|
||||||
|
Loading…
Reference in New Issue
Block a user