Skip to content

Commit f422a45

Browse files
authored
Merge pull request #8 from hepingood/dev
fix: fix string buffer bugs
2 parents 91f87bc + 4162a1d commit f422a45

File tree

12 files changed

+44
-25
lines changed

12 files changed

+44
-25
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ LibDriver MAX30105 is the full function driver of MAX30105 launched by LibDriver
3939

4040
/project includes the common Linux and MCU development board sample code. All projects use the shell script to debug the driver and the detail instruction can be found in each project's README.md.
4141

42+
/misra includes the LibDriver MISRA code scanning results.
43+
4244
### Install
4345

4446
Reference /interface IIC platform independent template and finish your platform IIC driver.

README_de.md

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ LibDriver MAX30105 ist der Treiber mit vollem Funktionsumfang von MAX30105, der
3939

4040
/project enthält den allgemeinen Beispielcode für Linux- und MCU-Entwicklungsboards. Alle Projekte verwenden das Shell-Skript, um den Treiber zu debuggen, und die detaillierten Anweisungen finden Sie in der README.md jedes Projekts.
4141

42+
/misra enthält die Ergebnisse des LibDriver MISRA Code Scans.
43+
4244
### Installieren
4345

4446
Verweisen Sie auf eine plattformunabhängige IIC-Schnittstellenvorlage und stellen Sie Ihren Plattform-IIC-Treiber fertig.

README_ja.md

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ LibDriver MAX30105は、LibDriverによって起動されたMAX30105の全機能
3939

4040
/ projectディレクトリには、一般的に使用されるLinuxおよびマイクロコントローラー開発ボードのプロジェクトサンプルが含まれています。 すべてのプロジェクトは、デバッグ方法としてシェルスクリプトを使用しています。詳細については、各プロジェクトのREADME.mdを参照してください。
4141

42+
/ misraはLibDriver misraコードスキャン結果を含む。
43+
4244
### インストール
4345

4446
/ interfaceディレクトリにあるプラットフォームに依存しないIICバステンプレートを参照して、指定したプラットフォームのIICバスドライバを完成させます。

README_ko.md

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ LibDriver MAX30105는 LibDriver에서 출시한 MAX30105의 전체 기능 드라
3939

4040
/project 디렉토리에는 일반적으로 사용되는 Linux 및 마이크로컨트롤러 개발 보드의 프로젝트 샘플이 포함되어 있습니다. 모든 프로젝트는 디버깅 방법으로 셸 스크립트를 사용하며, 자세한 내용은 각 프로젝트의 README.md를 참조하십시오.
4141

42+
/misra 에는 LibDriver misra 코드 검색 결과가 포함됩니다.
43+
4244
### 설치
4345

4446
/interface 디렉토리에서 플랫폼 독립적인IIC 버스 템플릿을 참조하여 지정된 플랫폼에 대한 IIC버스 드라이버를 완성하십시오.

README_zh-Hans.md

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ LibDriver MAX30105是LibDriver推出的MAX30105的全功能驱动,该驱动提
3939

4040
/project目录包含了常用Linux与单片机开发板的工程样例。所有工程均采用shell脚本作为调试方法,详细内容可参考每个工程里面的README.md。
4141

42+
/misra目录包含了LibDriver MISRA代码扫描结果。
43+
4244
### 安装
4345

4446
参考/interface目录下与平台无关的IIC总线模板,完成指定平台的IIC总线驱动。

README_zh-Hant.md

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ LibDriver MAX30105是LibDriver推出的MAX30105的全功能驅動,該驅動提
3939

4040
/project目錄包含了常用Linux與單片機開發板的工程樣例。所有工程均採用shell腳本作為調試方法,詳細內容可參考每個工程裡面的README.md。
4141

42+
/misra目錄包含了LibDriver MISRA程式碼掃描結果。
43+
4244
### 安裝
4345

4446
參考/interface目錄下與平台無關的IIC總線模板,完成指定平台的IIC總線驅動。

project/raspberrypi4b/driver/src/raspberrypi4b_driver_max30105_interface.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,12 @@ void max30105_interface_delay_ms(uint32_t ms)
122122
void max30105_interface_debug_print(const char *const fmt, ...)
123123
{
124124
char str[256];
125-
uint8_t len;
125+
uint16_t len;
126126
va_list args;
127127

128128
memset((char *)str, 0, sizeof(char) * 256);
129129
va_start(args, fmt);
130-
vsnprintf((char *)str, 256, (char const *)fmt, args);
130+
vsnprintf((char *)str, 255, (char const *)fmt, args);
131131
va_end(args);
132132

133133
len = strlen((char *)str);

project/raspberrypi4b/src/main.c

+9-9
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ void max30105_receive_callback(uint8_t type)
118118
* @param[in] argc is arg numbers
119119
* @param[in] **argv is the arg address
120120
* @return status code
121-
* - 0 success
122-
* - 1 run failed
123-
* - 5 param is invalid
121+
* - 0 success
122+
* - 1 run failed
123+
* - 5 param is invalid
124124
* @note none
125125
*/
126126
uint8_t max30105(uint8_t argc, char **argv)
@@ -138,7 +138,7 @@ uint8_t max30105(uint8_t argc, char **argv)
138138
{"times", required_argument, NULL, 1},
139139
{NULL, 0, NULL, 0},
140140
};
141-
char type[32] = "unknow";
141+
char type[33] = "unknow";
142142
uint32_t times = 3;
143143

144144
/* if no params */
@@ -164,7 +164,7 @@ uint8_t max30105(uint8_t argc, char **argv)
164164
case 'h' :
165165
{
166166
/* set the type */
167-
memset(type, 0, sizeof(char) * 32);
167+
memset(type, 0, sizeof(char) * 33);
168168
snprintf(type, 32, "h");
169169

170170
break;
@@ -174,7 +174,7 @@ uint8_t max30105(uint8_t argc, char **argv)
174174
case 'i' :
175175
{
176176
/* set the type */
177-
memset(type, 0, sizeof(char) * 32);
177+
memset(type, 0, sizeof(char) * 33);
178178
snprintf(type, 32, "i");
179179

180180
break;
@@ -184,7 +184,7 @@ uint8_t max30105(uint8_t argc, char **argv)
184184
case 'p' :
185185
{
186186
/* set the type */
187-
memset(type, 0, sizeof(char) * 32);
187+
memset(type, 0, sizeof(char) * 33);
188188
snprintf(type, 32, "p");
189189

190190
break;
@@ -194,7 +194,7 @@ uint8_t max30105(uint8_t argc, char **argv)
194194
case 'e' :
195195
{
196196
/* set the type */
197-
memset(type, 0, sizeof(char) * 32);
197+
memset(type, 0, sizeof(char) * 33);
198198
snprintf(type, 32, "e_%s", optarg);
199199

200200
break;
@@ -204,7 +204,7 @@ uint8_t max30105(uint8_t argc, char **argv)
204204
case 't' :
205205
{
206206
/* set the type */
207-
memset(type, 0, sizeof(char) * 32);
207+
memset(type, 0, sizeof(char) * 33);
208208
snprintf(type, 32, "t_%s", optarg);
209209

210210
break;

project/stm32f407/EW/stm32f407.dep

+8-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@
44
<fileChecksum>300614197</fileChecksum>
55
<configuration>
66
<name>Release</name>
7-
<outputs />
7+
<outputs>
8+
<file>$PROJ_DIR$\..\usr\src\getopt.c</file>
9+
<file>$PROJ_DIR$\..\usr\src\system_stm32f4xx.c</file>
10+
<file>$PROJ_DIR$\..\usr\src\main.c</file>
11+
<file>$PROJ_DIR$\..\usr\src\stm32f4xx_hal_msp.c</file>
12+
<file>$PROJ_DIR$\..\usr\src\shell.c</file>
13+
<file>$PROJ_DIR$\..\usr\src\stm32f4xx_it.c</file>
14+
</outputs>
815
<forcedrebuild>
916
<name>[REBUILD_ALL]</name>
1017
</forcedrebuild>

project/stm32f407/driver/src/stm32f407_driver_max30105_interface.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,12 @@ void max30105_interface_delay_ms(uint32_t ms)
114114
void max30105_interface_debug_print(const char *const fmt, ...)
115115
{
116116
char str[256];
117-
uint8_t len;
117+
uint16_t len;
118118
va_list args;
119119

120120
memset((char *)str, 0, sizeof(char) * 256);
121121
va_start(args, fmt);
122-
vsnprintf((char *)str, 256, (char const *)fmt, args);
122+
vsnprintf((char *)str, 255, (char const *)fmt, args);
123123
va_end(args);
124124

125125
len = strlen((char *)str);

project/stm32f407/interface/src/uart.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -203,13 +203,13 @@ uint16_t uart_flush(void)
203203
uint16_t uart_print(const char *const fmt, ...)
204204
{
205205
char str[256];
206-
uint8_t len;
206+
uint16_t len;
207207
va_list args;
208208

209209
/* print to the buffer */
210210
memset((char *)str, 0, sizeof(char) * 256);
211211
va_start(args, fmt);
212-
vsnprintf((char *)str, 256, (char const *)fmt, args);
212+
vsnprintf((char *)str, 255, (char const *)fmt, args);
213213
va_end(args);
214214

215215
/* send the data */

project/stm32f407/usr/src/main.c

+9-9
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,9 @@ void max30105_receive_callback(uint8_t type)
151151
* @param[in] argc is arg numbers
152152
* @param[in] **argv is the arg address
153153
* @return status code
154-
* - 0 success
155-
* - 1 run failed
156-
* - 5 param is invalid
154+
* - 0 success
155+
* - 1 run failed
156+
* - 5 param is invalid
157157
* @note none
158158
*/
159159
uint8_t max30105(uint8_t argc, char **argv)
@@ -171,7 +171,7 @@ uint8_t max30105(uint8_t argc, char **argv)
171171
{"times", required_argument, NULL, 1},
172172
{NULL, 0, NULL, 0},
173173
};
174-
char type[32] = "unknow";
174+
char type[33] = "unknow";
175175
uint32_t times = 3;
176176

177177
/* if no params */
@@ -197,7 +197,7 @@ uint8_t max30105(uint8_t argc, char **argv)
197197
case 'h' :
198198
{
199199
/* set the type */
200-
memset(type, 0, sizeof(char) * 32);
200+
memset(type, 0, sizeof(char) * 33);
201201
snprintf(type, 32, "h");
202202

203203
break;
@@ -207,7 +207,7 @@ uint8_t max30105(uint8_t argc, char **argv)
207207
case 'i' :
208208
{
209209
/* set the type */
210-
memset(type, 0, sizeof(char) * 32);
210+
memset(type, 0, sizeof(char) * 33);
211211
snprintf(type, 32, "i");
212212

213213
break;
@@ -217,7 +217,7 @@ uint8_t max30105(uint8_t argc, char **argv)
217217
case 'p' :
218218
{
219219
/* set the type */
220-
memset(type, 0, sizeof(char) * 32);
220+
memset(type, 0, sizeof(char) * 33);
221221
snprintf(type, 32, "p");
222222

223223
break;
@@ -227,7 +227,7 @@ uint8_t max30105(uint8_t argc, char **argv)
227227
case 'e' :
228228
{
229229
/* set the type */
230-
memset(type, 0, sizeof(char) * 32);
230+
memset(type, 0, sizeof(char) * 33);
231231
snprintf(type, 32, "e_%s", optarg);
232232

233233
break;
@@ -237,7 +237,7 @@ uint8_t max30105(uint8_t argc, char **argv)
237237
case 't' :
238238
{
239239
/* set the type */
240-
memset(type, 0, sizeof(char) * 32);
240+
memset(type, 0, sizeof(char) * 33);
241241
snprintf(type, 32, "t_%s", optarg);
242242

243243
break;

0 commit comments

Comments
 (0)