Skip to content

Commit

Permalink
LocalPath : update to fix possible string overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
brunotl committed Oct 1, 2024
1 parent 0b9a74e commit 94b81d4
Show file tree
Hide file tree
Showing 46 changed files with 196 additions and 77 deletions.
11 changes: 0 additions & 11 deletions Common/Header/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,6 @@ void TrimRight(TCHAR* str);
// Parse string (new lines etc) and malloc the string
TCHAR* StringMallocParse(const TCHAR* old_string);

void LocalPath(TCHAR* buf, const TCHAR* file = TEXT("")) gcc_nonnull_all;
void LocalPath(TCHAR* buffer, const TCHAR* SubPath, const TCHAR* file) gcc_nonnull_all;

void SystemPath(TCHAR* buf, const TCHAR* file = TEXT("")) gcc_nonnull_all;
void SystemPath(TCHAR* buffer, const TCHAR* SubPath, const TCHAR* file) gcc_nonnull_all;

void RemoveFilePathPrefix(const TCHAR* szPrefix, TCHAR* szFilePath) gcc_nonnull_all;

const TCHAR *LKGetLocalPath();
const TCHAR *LKGetSystemPath();

void LK_tsplitpath(const TCHAR* path, TCHAR* drv, TCHAR* dir, TCHAR* name, TCHAR* ext);

void propGetFontSettingsFromString(const TCHAR *Buffer, LOGFONT* lplf);
Expand Down
1 change: 1 addition & 0 deletions Common/Source/AirfieldDetails.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "AirfieldDetails.h"
#include "Waypointparser.h"
#include "utils/zzip_stream.h"
#include "LocalPath.h"

void LookupAirfieldDetail(TCHAR *Name, TCHAR *Details) {
TCHAR UName[NAME_SIZE + 1];
Expand Down
1 change: 1 addition & 0 deletions Common/Source/Airspace/LKAirspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "Library/TimeFunctions.h"
#include "Baro.h"
#include "utils/lookup_table.h"
#include "LocalPath.h"

using xml_document = rapidxml::xml_document<char>;
using xml_attribute = rapidxml::xml_attribute<char>;
Expand Down
1 change: 1 addition & 0 deletions Common/Source/Bitmaps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "Bitmaps.h"
#include "resource_data.h"
#include "Asset.hpp"
#include "LocalPath.h"


using std::placeholders::_1;
Expand Down
1 change: 1 addition & 0 deletions Common/Source/Calc/DoRecent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

#include "externs.h"
#include "LocalPath.h"

namespace {

Expand Down
1 change: 1 addition & 0 deletions Common/Source/Comm/FilePort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <functional>
#include "utils/stringext.h"
#include "OS/Sleep.h"
#include "LocalPath.h"

using namespace std::placeholders;

Expand Down
1 change: 1 addition & 0 deletions Common/Source/Devices/DeviceSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "externs.h"
#include "Utils.h"
#include <fstream>
#include "LocalPath.h"

namespace {

Expand Down
1 change: 1 addition & 0 deletions Common/Source/Devices/devLXNano3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "utils/printf.h"
#include "Comm/UpdateQNH.h"
#include "Comm/ExternalWind.h"
#include "LocalPath.h"

#define NANO_PROGRESS_DLG
#define BLOCK_SIZE 32
Expand Down
1 change: 1 addition & 0 deletions Common/Source/Dialogs/dlgChecklist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "resource.h"
#include "utils/zzip_stream.h"
#include <vector>
#include "LocalPath.h"


#define MAXNOTETITLE 200 // max number of characters in a title note
Expand Down
7 changes: 3 additions & 4 deletions Common/Source/Dialogs/dlgEOSIGCDownload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "dlgIGCProgress.h"
#include "utils/tokenizer.h"
#include "utils/printf.h"
#include "LocalPath.h"

#define EOS_PRPGRESS_DLG

Expand Down Expand Up @@ -201,10 +202,8 @@ static void OnMultiSelectListListInfo(WndListFrame *Sender, WndListFrame::ListIn
}

}

bool GetEOSIGCFilename(TCHAR *IGCFilename, TCHAR *InFilename) {
if (IGCFilename == NULL)
return false;
static
bool GetEOSIGCFilename(TCHAR (&IGCFilename)[MAX_PATH], TCHAR *InFilename) {
TCHAR Tmp[MAX_PATH];

_tcscpy(Tmp, InFilename);
Expand Down
7 changes: 3 additions & 4 deletions Common/Source/Dialogs/dlgFlarmIGCDownload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "dlgFlarmIGCDownload.h"
#include "utils/tokenizer.h"
#include "utils/printf.h"
#include "LocalPath.h"

#define MAX_FLARM_ANSWER_LEN 640
// FLARM Docu does not tell the max. answer len
Expand Down Expand Up @@ -367,11 +368,9 @@ static void OnMultiSelectListListInfo(WndListFrame *Sender,
}
}

bool GetIGCFilename(TCHAR *IGCFilename, int Idx) {
if (IGCFilename == NULL)
return false;
static
bool GetIGCFilename(TCHAR (&IGCFilename)[MAX_PATH], int Idx) {
TCHAR Tmp[MAX_PATH];

_tcscpy(Tmp, IGCFileList.at(Idx).Line1);
TCHAR *Filename = lk::tokenizer<TCHAR>(Tmp).Next(TEXT(" "));
if(Filename) {
Expand Down
1 change: 1 addition & 0 deletions Common/Source/Dialogs/dlgIgcFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <iterator>
#include "utils/stl_utils.h"
#include "resource.h"
#include "LocalPath.h"

#ifdef ANDROID
#include "Android/LK8000Activity.h"
Expand Down
6 changes: 3 additions & 3 deletions Common/Source/Dialogs/dlgLXIGCDownload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "dlgLXIGCDownload.h"
#include "utils/tokenizer.h"
#include "utils/printf.h"
#include "LocalPath.h"

#define LST_STRG_LEN 100

Expand Down Expand Up @@ -167,9 +168,8 @@ static void OnMultiSelectListListInfo(WndListFrame *Sender, WndListFrame::ListIn

}

bool GetLXIGCFilename(TCHAR *IGCFilename, TCHAR *InFilename) {
if (IGCFilename == NULL)
return false;
static
bool GetLXIGCFilename(TCHAR (&IGCFilename)[MAX_PATH], TCHAR *InFilename) {
TCHAR Tmp[MAX_PATH];

_tcscpy(Tmp, InFilename);
Expand Down
1 change: 1 addition & 0 deletions Common/Source/Dialogs/dlgProfiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "WindowControls.h"
#include "resource.h"
#include "utils/printf.h"
#include "LocalPath.h"

static WndForm *wf=NULL;
static short profilemode=0;
Expand Down
1 change: 1 addition & 0 deletions Common/Source/Dialogs/dlgStartup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "InfoBoxLayout.h"
#include "LKInterface.h"
#include "utils/printf.h"
#include "LocalPath.h"

#ifdef KOBO
#include "Kobo/Kernel.hpp"
Expand Down
1 change: 1 addition & 0 deletions Common/Source/Dialogs/dlgTaskOverview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "resource.h"
#include "utils/printf.h"
#include "Waypoints/SetHome.h"
#include "LocalPath.h"

#ifdef ANDROID
#include "Android/LK8000Activity.h"
Expand Down
1 change: 1 addition & 0 deletions Common/Source/Draw/LoadSplash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "externs.h"
#include "resource.h"
#include "ScreenGeometry.h"
#include "LocalPath.h"

#ifdef USE_GDI
#define IMG_EXT "BMP"
Expand Down
1 change: 1 addition & 0 deletions Common/Source/FlarmIdFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "utils/zzip_stream.h"
#include "utils/charset_helper.h"
#include <iostream>
#include "LocalPath.h"

namespace {

Expand Down
1 change: 1 addition & 0 deletions Common/Source/FlarmTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "utils/zzip_stream.h"
#include <unordered_map>
#include <memory>
#include "LocalPath.h"

namespace {

Expand Down
1 change: 1 addition & 0 deletions Common/Source/InputEvents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "utils/lookup_table.h"
#include <type_traits>
#include "Waypoints/SetHome.h"
#include "LocalPath.h"
// uncomment for show all menu button with id as Label.
//#define TEST_MENU_LAYOUT

Expand Down
1 change: 1 addition & 0 deletions Common/Source/LKInstall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#endif
#endif
#include "utils/openzip.h"
#include "LocalPath.h"



Expand Down
1 change: 1 addition & 0 deletions Common/Source/LKLanguage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "utils/zzip_stream.h"
#include "picojson.h"
#include <istream>
#include "LocalPath.h"
#ifdef ANDROID
#include "Android/Main.hpp"
#include "Android/NativeView.hpp"
Expand Down
1 change: 1 addition & 0 deletions Common/Source/LKProfileLoad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <Tracking/Tracking.h>
#include "utils/printf.h"
#include "utils/unique_file_ptr.h"
#include "LocalPath.h"

#ifdef ANDROID
#include "Android/BluetoothHelper.hpp"
Expand Down
1 change: 1 addition & 0 deletions Common/Source/LKUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "Library/TimeFunctions.h"
#include "Baro.h"
#include "InputEvents.h"
#include "LocalPath.h"

extern TCHAR LastTaskFileName[MAX_PATH];

Expand Down
1 change: 1 addition & 0 deletions Common/Source/Library/DirectoryFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

#include "externs.h"
#include "LocalPath.h"

void CreateDirectoryIfAbsent(const TCHAR *filename) {
TCHAR fullname[MAX_PATH];
Expand Down
Loading

0 comments on commit 94b81d4

Please sign in to comment.