Changeset c319945 in rtems


Ignore:
Timestamp:
Mar 13, 2019, 3:07:23 PM (5 weeks ago)
Author:
Joel Sherrill <joel@…>
Branches:
master
Children:
31e8f1b
Parents:
11eb818
git-author:
Joel Sherrill <joel@…> (03/13/19 15:07:23)
git-committer:
Joel Sherrill <joel@…> (03/14/19 13:21:44)
Message:

main_edit.c: Use strncpy() to eliminate potential buffer overflow.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libmisc/shell/main_edit.c

    r11eb818 rc319945  
    287287  struct editor *start = ed;
    288288
    289   if (!realpath(filename, fn)) strcpy(fn, filename);
     289  if (!realpath(filename, fn)) strncpy(fn, filename, FILENAME_MAX);
    290290
    291291  do {
     
    298298static int new_file(struct editor *ed, char *filename) {
    299299  if (*filename) {
    300     strcpy(ed->filename, filename);
     300    strncpy(ed->filename, filename, FILENAME_MAX);
    301301  } else {
    302302    sprintf(ed->filename, "Untitled-%d", ++ed->env->untitled);
     
    17531753    pos += n;
    17541754  }
    1755   strcpy(ed->filename, "<stdin>");
     1755  strncpy(ed->filename, "<stdin>", FILENAME_MAX);
    17561756  ed->newfile = 1;
    17571757  ed->dirty = 0;
     
    17761776      }
    17771777    }
    1778     strcpy(ed->filename, (const char*) ed->env->linebuf);
     1778    strncpy(
     1779      ed->filename, (const char*) ed->env->linebuf, FILENAME_MAX);
    17791780    ed->newfile = 0;
    17801781  }
Note: See TracChangeset for help on using the changeset viewer.