Skip to content

Commit b7b2c2f

Browse files
tobluxandreas-gaisler
authored andcommitted
sparc: Replace deprecated strcpy() with strscpy() in prom_32.c
strcpy() is deprecated; use strscpy() instead. No functional changes intended. Link: KSPP#88 Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Reviewed-by: Andreas Larsson <andreas@gaisler.com> Signed-off-by: Andreas Larsson <andreas@gaisler.com>
1 parent dcdba59 commit b7b2c2f

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

arch/sparc/kernel/prom_32.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,14 +187,16 @@ char * __init build_path_component(struct device_node *dp)
187187
{
188188
const char *name = of_get_property(dp, "name", NULL);
189189
char tmp_buf[64], *n;
190+
size_t n_sz;
190191

191192
tmp_buf[0] = '\0';
192193
__build_path_component(dp, tmp_buf);
193194
if (tmp_buf[0] == '\0')
194-
strcpy(tmp_buf, name);
195+
strscpy(tmp_buf, name);
195196

196-
n = prom_early_alloc(strlen(tmp_buf) + 1);
197-
strcpy(n, tmp_buf);
197+
n_sz = strlen(tmp_buf) + 1;
198+
n = prom_early_alloc(n_sz);
199+
strscpy(n, tmp_buf, n_sz);
198200

199201
return n;
200202
}
@@ -204,13 +206,14 @@ extern void restore_current(void);
204206
void __init of_console_init(void)
205207
{
206208
char *msg = "OF stdout device is: %s\n";
209+
const size_t of_console_path_sz = 256;
207210
struct device_node *dp;
208211
unsigned long flags;
209212
const char *type;
210213
phandle node;
211214
int skip, tmp, fd;
212215

213-
of_console_path = prom_early_alloc(256);
216+
of_console_path = prom_early_alloc(of_console_path_sz);
214217

215218
switch (prom_vers) {
216219
case PROM_V0:
@@ -297,7 +300,7 @@ void __init of_console_init(void)
297300
prom_printf("No stdout-path in root node.\n");
298301
prom_halt();
299302
}
300-
strcpy(of_console_path, path);
303+
strscpy(of_console_path, path, of_console_path_sz);
301304
}
302305
break;
303306
}

0 commit comments

Comments
 (0)