3434#include " rs274ngc_interp.hh"
3535#include " python_plugin.hh"
3636#include " interp_python.hh"
37- #include < rtapi_string.h>
37+ #include < rtapi_string.h> // rtapi_strlcpy()
3838
3939namespace bp = boost::python;
4040
@@ -60,7 +60,7 @@ int Interp::findFile( // ARGUMENTS
6060 snprintf (targetPath, PATH_MAX, " %s/%s" , direct, target);
6161 file = fopen (targetPath, " r" );
6262 if (file) {
63- strncpy (foundFileDirect, direct, PATH_MAX);
63+ rtapi_strlcpy (foundFileDirect, direct, PATH_MAX);
6464 fclose (file);
6565 return INTERP_OK;
6666 }
@@ -71,8 +71,8 @@ int Interp::findFile( // ARGUMENTS
7171
7272 while ((aFile = readdir (aDir))) {
7373 if (aFile->d_type == DT_DIR &&
74- (0 != strcmp (aFile->d_name , " .." )) &&
75- (0 != strcmp (aFile->d_name , " ." ))) {
74+ (0 != strncmp (aFile->d_name , " .." , 3 )) &&
75+ (0 != strncmp (aFile->d_name , " ." , 2 ))) {
7676
7777 char path[PATH_MAX+1 ];
7878 snprintf (path, PATH_MAX, " %s/%s" , direct, aFile->d_name );
@@ -561,7 +561,7 @@ int Interp::control_back_to( block_pointer block, // pointer to block
561561 newFP = fopen (op->filename , " r" );
562562 // set the line number
563563 settings->sequence_number = 0 ;
564- strncpy (settings->filename , op->filename , sizeof (settings->filename ));
564+ rtapi_strlcpy (settings->filename , op->filename , sizeof (settings->filename ));
565565 if (settings->filename [sizeof (settings->filename )-1 ] != ' \0 ' ) {
566566 fclose (settings->file_pointer );
567567 logOword (" filename too long: %s" , op->filename );
@@ -597,7 +597,7 @@ int Interp::control_back_to( block_pointer block, // pointer to block
597597 if (settings->file_pointer )
598598 fclose (settings->file_pointer );
599599 settings->file_pointer = newFP;
600- strncpy (settings->filename , newFileName, sizeof (settings->filename ));
600+ rtapi_strlcpy (settings->filename , newFileName, sizeof (settings->filename ));
601601 if (settings->filename [sizeof (settings->filename )-1 ] != ' \0 ' ) {
602602 logOword (" new filename '%s' is too long (max len %zu)\n " , newFileName, sizeof (settings->filename )-1 );
603603 settings->filename [sizeof (settings->filename )-1 ] = ' \0 ' ; // oh well, truncate the filename
0 commit comments