@@ -489,7 +489,7 @@ uint32_t ApplXcpGetId(uint8_t id, uint8_t* buf, uint32_t bufLen) {
489
489
if (gXcpA2lName == NULL ) return 0 ;
490
490
len = (uint32_t )strlen (gXcpA2lName );
491
491
if (buf ) {
492
- if (len >= bufLen ) return 0 ; // Insufficient buffer space
492
+ if (len >= bufLen - 1 ) return 0 ; // Insufficient buffer space
493
493
strncpy ((char * )buf , gXcpA2lName , len );
494
494
}
495
495
break ;
@@ -498,7 +498,7 @@ uint32_t ApplXcpGetId(uint8_t id, uint8_t* buf, uint32_t bufLen) {
498
498
if (gXcpA2lName == NULL ) return 0 ;
499
499
len = (uint32_t )strlen (gXcpA2lName )+ 4 ;
500
500
if (buf ) {
501
- if (len > bufLen ) return 0 ; // Insufficient buffer space
501
+ if (len > bufLen - 1 ) return 0 ; // Insufficient buffer space
502
502
SNPRINTF ((char * )buf , bufLen , "%s.a2l" , gXcpA2lName );
503
503
}
504
504
break ;
@@ -510,8 +510,8 @@ uint32_t ApplXcpGetId(uint8_t id, uint8_t* buf, uint32_t bufLen) {
510
510
#ifdef XCP_ENABLE_IDT_A2L_UPLOAD
511
511
case IDT_ASAM_UPLOAD :
512
512
{
513
- char filename [512 ];
514
- SNPRINTF ((char * )filename , 256 , "%s.a2l" , gXcpA2lName );
513
+ char filename [256 ];
514
+ SNPRINTF ((char * )filename , 255 , "%s.a2l" , gXcpA2lName );
515
515
if (NULL == (gXcpFile = loadFile (filename ,& gXcpFileLength ))) return 0 ;
516
516
len = gXcpFileLength ;
517
517
}
@@ -524,7 +524,7 @@ uint32_t ApplXcpGetId(uint8_t id, uint8_t* buf, uint32_t bufLen) {
524
524
if (buf ) {
525
525
uint8_t addr [4 ];
526
526
if (socketGetLocalAddr (NULL , addr )) {
527
- SNPRINTF ((char * )buf , bufLen , "http://%u.%u.%u.%u:%u/file/%s.a2l" , addr [0 ], addr [1 ], addr [2 ], addr [3 ], gOptionHTTPPort , gXcpA2lName );
527
+ SNPRINTF ((char * )buf , bufLen - 1 , "http://%u.%u.%u.%u:%u/file/%s.a2l" , addr [0 ], addr [1 ], addr [2 ], addr [3 ], gOptionHTTPPort , gXcpA2lName );
528
528
len = (uint32_t )strlen ((char * )buf );
529
529
}
530
530
}
0 commit comments