1
1
/*
2
2
* Copyright (c) 2024, Intel Corporation. All rights reserved.
3
+ * Copyright (c) 2025, Altera Corporation. All rights reserved.
3
4
*
4
5
* SPDX-License-Identifier: BSD-3-Clause
5
6
*/
20
21
21
22
#include <socfpga_ros.h>
22
23
24
+ #define WORD_SIZE (sizeof(uint32_t))
25
+
23
26
static void swap_bits (char * const data , uint32_t len )
24
27
{
25
28
uint32_t x , y ;
@@ -99,7 +102,8 @@ static uint32_t load_and_check_spt(spt_table_t *spt_ptr, size_t offset)
99
102
return ROS_IMAGE_PARTNUM_OVFL ;
100
103
}
101
104
102
- memcpy_s (& spt_data , SPT_SIZE , spt_ptr , SPT_SIZE );
105
+ memcpy_s (& spt_data , (sizeof (spt_table_t ) / WORD_SIZE ),
106
+ spt_ptr , (SPT_SIZE / WORD_SIZE ));
103
107
spt_data .checksum = 0U ;
104
108
swap_bits ((char * )& spt_data , SPT_SIZE );
105
109
@@ -153,6 +157,7 @@ uint32_t ros_qspi_get_ssbl_offset(unsigned long *offset)
153
157
}
154
158
155
159
uint32_t ret , img_index ;
160
+ size_t len ;
156
161
char ssbl_name [SPT_PARTITION_NAME_LENGTH ];
157
162
static spt_table_t spt ;
158
163
@@ -168,11 +173,12 @@ uint32_t ros_qspi_get_ssbl_offset(unsigned long *offset)
168
173
169
174
if (strncmp (spt .partition [img_index ].name , FACTORY_IMAGE ,
170
175
SPT_PARTITION_NAME_LENGTH ) == 0U ) {
171
- strlcpy (ssbl_name , FACTORY_SSBL , SPT_PARTITION_NAME_LENGTH );
176
+ strcpy_secure (ssbl_name , SPT_PARTITION_NAME_LENGTH , FACTORY_SSBL );
172
177
} else {
173
- strlcpy (ssbl_name , spt .partition [img_index ].name ,
174
- SPT_PARTITION_NAME_LENGTH );
175
- strlcat (ssbl_name , SSBL_SUFFIX , SPT_PARTITION_NAME_LENGTH );
178
+ strcpy_secure (ssbl_name , SPT_PARTITION_NAME_LENGTH , SSBL_PREFIX );
179
+ len = strnlen_secure (ssbl_name , SPT_PARTITION_NAME_LENGTH );
180
+ strcpy_secure (ssbl_name + len , SPT_PARTITION_NAME_LENGTH - len ,
181
+ spt .partition [img_index ].name );
176
182
}
177
183
178
184
for (uint32_t index = 0U ; index < spt .partitions ; index ++ ) {
0 commit comments