From 580ede82df26df4ec55fc0e0741247e0ea98af06 Mon Sep 17 00:00:00 2001 From: Florian Pose Date: Fri, 3 Apr 2020 11:45:15 +0200 Subject: [PATCH] Fixed possible file name overflow. --- tool/CommandFoeRead.cpp | 4 ++-- tool/CommandFoeWrite.cpp | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tool/CommandFoeRead.cpp b/tool/CommandFoeRead.cpp index 7221f40b..c0666a44 100644 --- a/tool/CommandFoeRead.cpp +++ b/tool/CommandFoeRead.cpp @@ -1,6 +1,6 @@ /***************************************************************************** * - * $Id$ + * $Id: CommandFoeRead.cpp,v 4f682084c643 2010/10/25 08:12:26 fp $ * * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH * @@ -105,7 +105,7 @@ void CommandFoeRead::execute(const StringVector &args) data.buffer_size = 0x8800; data.buffer = new uint8_t[data.buffer_size]; - strncpy(data.file_name, args[0].c_str(), sizeof(data.file_name)); + strncpy(data.file_name, args[0].c_str(), sizeof(data.file_name) - 1); try { m.readFoe(&data); diff --git a/tool/CommandFoeWrite.cpp b/tool/CommandFoeWrite.cpp index abd6a3fb..58a12117 100644 --- a/tool/CommandFoeWrite.cpp +++ b/tool/CommandFoeWrite.cpp @@ -1,6 +1,6 @@ /***************************************************************************** * - * $Id$ + * $Id: CommandFoeWrite.cpp,v 4f682084c643 2010/10/25 08:12:26 fp $ * * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH * @@ -140,7 +140,8 @@ void CommandFoeWrite::execute(const StringVector &args) // write data via foe to the slave data.offset = 0; - strncpy(data.file_name, storeFileName.c_str(), sizeof(data.file_name)); + strncpy(data.file_name, storeFileName.c_str(), + sizeof(data.file_name) - 1); try { m.writeFoe(&data);