← Back to team overview

kicad-developers team mailing list archive

[PATCH] two minor fixes

 

First patch fixes the Save library file as dialog which had the library
extension instead of library extension wildcard used.

Second patch fixes a null termination in eeschema/cross-probing.cpp. The
char array line is in block scope and is never preinitialized to all 0s.
There's also no guarantee for strncpy to actually copy null if size of
bytes to read == buffer size passed. We need to set the last byte of line
to NULL after strncpy as insurance.
From 794636c7ff10ea98edd55b98457988196b66b3c6 Mon Sep 17 00:00:00 2001
From: Mark Roszko <mark.roszko@xxxxxxxxx>
Date: Fri, 16 Jan 2015 00:43:11 -0500
Subject: [PATCH 1/2] Use the wildcard file extension in the library editor
 save as dialog

---
 eeschema/libedit.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/eeschema/libedit.cpp b/eeschema/libedit.cpp
index f9ed007..f474736 100644
--- a/eeschema/libedit.cpp
+++ b/eeschema/libedit.cpp
@@ -335,7 +335,7 @@ bool LIB_EDIT_FRAME::SaveActiveLibrary( bool newFile )
             default_path = search->LastVisitedPath();
 
         wxFileDialog dlg( this, _( "Part Library Name:" ), default_path,
-                          wxEmptyString, SchematicLibraryFileExtension,
+                          wxEmptyString, SchematicLibraryFileWildcard,
                           wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
 
         if( dlg.ShowModal() == wxID_CANCEL )
-- 
1.9.1

From 6ae28bfa50cc3588b1bdf99d4fc4d9e3c510190f Mon Sep 17 00:00:00 2001
From: Mark Roszko <mark.roszko@xxxxxxxxx>
Date: Fri, 16 Jan 2015 01:24:29 -0500
Subject: [PATCH 2/2] Ensure null termination of c string after using strncpy
 because the line buffer is not preinitialized

---
 eeschema/cross-probing.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/eeschema/cross-probing.cpp b/eeschema/cross-probing.cpp
index 59697b5..c22d546 100644
--- a/eeschema/cross-probing.cpp
+++ b/eeschema/cross-probing.cpp
@@ -62,6 +62,7 @@ void SCH_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
     char     line[1024];
 
     strncpy( line, cmdline, sizeof(line) - 1 );
+	line[ sizeof(line) - 1 ] = '\0';
 
     char* idcmd = strtok( line, " \n\r" );
     char* text  = strtok( NULL, "\"\n\r" );
-- 
1.9.1


Follow ups