From b3545fcab7cf2b9127ca05d20abff04c0cc1304e Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 5 Aug 2024 11:58:21 +0200 Subject: [PATCH] vi: correct mistake in strings assignment remove some useless code --- bld/vi/win/ctl/setfs.c | 6 ++++-- bld/vi/win/linedlg.c | 5 ++--- bld/vi/win/snoop.c | 10 +++++----- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/bld/vi/win/ctl/setfs.c b/bld/vi/win/ctl/setfs.c index 573fe47dce..bbc6dd0fd3 100644 --- a/bld/vi/win/ctl/setfs.c +++ b/bld/vi/win/ctl/setfs.c @@ -252,10 +252,12 @@ static void fs_set( void *dlg, ctl_elt *ctl, void *data ) ((dlg_data *)dlg)->ShowMatch = *(bool *)data; break; case SETFS_TAGS_FILENAME: - ((dlg_data *)dlg)->TagFileName = *(char **)data; + strncpy( ((dlg_data *)dlg)->TagFileName, *(char **)data, TAGFILENAMEWIDTH - 1 ); + ((dlg_data *)dlg)->TagFileName[TAGFILENAMEWIDTH - 1] = '\0'; break; case SETFS_MISC_GREP: - ((dlg_data *)dlg)->GrepDefault = *(char **)data; + strncpy( ((dlg_data *)dlg)->GrepDefault, *(char **)data, GREPDEFAULTWIDTH - 1 ); + ((dlg_data *)dlg)->GrepDefault[GREPDEFAULTWIDTH - 1] = '\0'; break; } } diff --git a/bld/vi/win/linedlg.c b/bld/vi/win/linedlg.c index 809770b345..6c9f7905dd 100644 --- a/bld/vi/win/linedlg.c +++ b/bld/vi/win/linedlg.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2019 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2024 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -40,7 +40,6 @@ WINEXPORT INT_PTR CALLBACK GotoLineDlgProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ); static char lineStr[20]; -static char lineLen = sizeof( lineStr ) - 1; static linenum *lineVal; /* @@ -63,7 +62,7 @@ WINEXPORT INT_PTR CALLBACK GotoLineDlgProc( HWND hwnd, UINT msg, WPARAM wparam, EndDialog( hwnd, FALSE ); break; case IDOK: - GetDlgItemText( hwnd, GOTOLINE_EDIT, lineStr, lineLen ); + GetDlgItemText( hwnd, GOTOLINE_EDIT, lineStr, sizeof( lineStr ) ); *lineVal = atol( lineStr ); if( *lineVal > 0 ) { EndDialog( hwnd, TRUE ); diff --git a/bld/vi/win/snoop.c b/bld/vi/win/snoop.c index a613312ff4..501f78e4fb 100644 --- a/bld/vi/win/snoop.c +++ b/bld/vi/win/snoop.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2024 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -142,7 +142,7 @@ WINEXPORT INT_PTR CALLBACK SnoopDlgProc( HWND hwnd, UINT msg, WPARAM wparam, LPA bi.lpszTitle = buffer1; bi.ulFlags = BIF_RETURNONLYFSDIRS; bi.lpfn = BrowseCallbackProc; - GetDlgItemText( hwnd, SNOOP_PATH, buffer2, MAX_PATH ); + GetDlgItemText( hwnd, SNOOP_PATH, buffer2, sizeof( buffer2 ) ); bi.lParam = (LPARAM)buffer2; if( (pidl = pfnSHBrowseForFolder( &bi )) != NULL ) { if( pfnSHGetPathFromIDList( pidl, buffer1 ) ) { @@ -156,11 +156,11 @@ WINEXPORT INT_PTR CALLBACK SnoopDlgProc( HWND hwnd, UINT msg, WPARAM wparam, LPA EndDialog( hwnd, FALSE ); break; case IDOK: - GetDlgItemText( hwnd, SNOOP_STRING, snoop, MAX_INPUT_LINE ); + GetDlgItemText( hwnd, SNOOP_STRING, snoop, sizeof( snoop ) ); ReplaceString( &snoopData.find, snoop ); - GetDlgItemText( hwnd, SNOOP_EXT, snoop, MAX_INPUT_LINE ); + GetDlgItemText( hwnd, SNOOP_EXT, snoop, sizeof( snoop ) ); ReplaceString( &snoopData.ext, snoop ); - GetDlgItemText( hwnd, SNOOP_PATH, snoop, MAX_INPUT_LINE ); + GetDlgItemText( hwnd, SNOOP_PATH, snoop, sizeof( snoop ) ); ReplaceString( &snoopData.path, snoop ); snoopData.case_ignore = IsDlgButtonChecked( hwnd, SNOOP_IGNORE_CASE ); snoopData.use_regexp = IsDlgButtonChecked( hwnd, SNOOP_REGULAR_EXPRESSIONS );