mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 04:46:55 +03:00
* screen.c (string_file_name): Fix possible off-by-one
buffer overflow. (string_file_size): Avoid unsafe strcpy(). (string_file_size_brief): Likewise. Eliminate buffer array.
This commit is contained in:
parent
0d1ef44182
commit
aec8a76263
@ -1,3 +1,10 @@
|
|||||||
|
2002-09-09 Andrew V. Samoilov <sav@bcs.zp.ua>
|
||||||
|
|
||||||
|
* screen.c (string_file_name): Fix possible off-by-one
|
||||||
|
buffer overflow.
|
||||||
|
(string_file_size): Avoid unsafe strcpy().
|
||||||
|
(string_file_size_brief): Likewise. Eliminate buffer array.
|
||||||
|
|
||||||
2002-09-08 Pavel Roskin <proski@gnu.org>
|
2002-09-08 Pavel Roskin <proski@gnu.org>
|
||||||
|
|
||||||
* color.c: Move hascolors variable into init_colors(). Adjust
|
* color.c: Move hascolors variable into init_colors(). Adjust
|
||||||
|
13
src/screen.c
13
src/screen.c
@ -148,7 +148,7 @@ string_file_name (file_entry *fe, int len)
|
|||||||
static char buffer [BUF_SMALL];
|
static char buffer [BUF_SMALL];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < sizeof(buffer); i++) {
|
for (i = 0; i < sizeof(buffer) - 1; i++) {
|
||||||
char c;
|
char c;
|
||||||
|
|
||||||
c = fe->fname[i];
|
c = fe->fname[i];
|
||||||
@ -174,8 +174,7 @@ string_file_size (file_entry *fe, int len)
|
|||||||
|
|
||||||
/* Don't ever show size of ".." since we don't calculate it */
|
/* Don't ever show size of ".." since we don't calculate it */
|
||||||
if (!strcmp (fe->fname, "..")) {
|
if (!strcmp (fe->fname, "..")) {
|
||||||
strcpy (buffer, _("UP--DIR"));
|
return _("UP--DIR");
|
||||||
return buffer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_ST_RDEV
|
#ifdef HAVE_ST_RDEV
|
||||||
@ -195,16 +194,12 @@ string_file_size (file_entry *fe, int len)
|
|||||||
static const char *
|
static const char *
|
||||||
string_file_size_brief (file_entry *fe, int len)
|
string_file_size_brief (file_entry *fe, int len)
|
||||||
{
|
{
|
||||||
static char buffer [BUF_TINY];
|
|
||||||
|
|
||||||
if (S_ISLNK (fe->buf.st_mode) && !fe->f.link_to_dir) {
|
if (S_ISLNK (fe->buf.st_mode) && !fe->f.link_to_dir) {
|
||||||
strcpy (buffer, _("SYMLINK"));
|
return _("SYMLINK");
|
||||||
return buffer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((S_ISDIR (fe->buf.st_mode) || fe->f.link_to_dir) && strcmp (fe->fname, "..")) {
|
if ((S_ISDIR (fe->buf.st_mode) || fe->f.link_to_dir) && strcmp (fe->fname, "..")) {
|
||||||
strcpy (buffer, _("SUB-DIR"));
|
return _("SUB-DIR");
|
||||||
return buffer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return string_file_size (fe, len);
|
return string_file_size (fe, len);
|
||||||
|
Loading…
Reference in New Issue
Block a user