Commit 06c3f1d6 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] ppc64: fix saved_command_line/cmd_line lengths

From: Anton Blanchard <anton@samba.org>

cmd_line was twice the size of saved_command_line but we did a strcpy from
the larger into the smaller.  Create COMMAND_LINE_SIZE and use it.
parent 2115cc34
......@@ -53,7 +53,7 @@ extern void ppc6xx_idle(void);
extern void power4_idle(void);
extern boot_infos_t *boot_infos;
char saved_command_line[256];
char saved_command_line[COMMAND_LINE_SIZE];
unsigned char aux_device_present;
struct ide_machdep_calls ppc_ide_md;
char *sysmap;
......@@ -501,7 +501,7 @@ void parse_bootinfo(struct bi_record *rec)
ulong *data = rec->data;
switch (rec->tag) {
case BI_CMD_LINE:
memcpy(cmd_line, (void *)data, rec->size);
strlcpy(cmd_line, (void *)data, sizeof(cmd_line));
break;
case BI_SYSMAP:
sysmap = (char *)((data[0] >= (KERNELBASE)) ? data[0] :
......@@ -538,7 +538,7 @@ machine_init(unsigned long r3, unsigned long r4, unsigned long r5,
unsigned long r6, unsigned long r7)
{
#ifdef CONFIG_CMDLINE
strcpy(cmd_line, CONFIG_CMDLINE);
strlcpy(cmd_line, CONFIG_CMDLINE, sizeof(cmd_line));
#endif /* CONFIG_CMDLINE */
#ifdef CONFIG_6xx
......@@ -676,7 +676,7 @@ void __init setup_arch(char **cmdline_p)
init_mm.brk = (unsigned long) klimit;
/* Save unparsed command line copy for /proc/cmdline */
strcpy(saved_command_line, cmd_line);
strlcpy(saved_command_line, cmd_line, sizeof(saved_command_line));
*cmdline_p = cmd_line;
/* set up the bootmem stuff with available memory */
......
......@@ -80,7 +80,7 @@ unsigned long decr_overclock_proc0_set = 0;
int powersave_nap;
char saved_command_line[256];
char saved_command_line[COMMAND_LINE_SIZE];
unsigned char aux_device_present;
void parse_cmd_line(unsigned long r3, unsigned long r4, unsigned long r5,
......@@ -536,7 +536,7 @@ int parse_bootinfo(void)
for ( ; rec->tag != BI_LAST ; rec = bi_rec_next(rec) ) {
switch (rec->tag) {
case BI_CMD_LINE:
memcpy(cmd_line, (void *)rec->data, rec->size);
strlcpy(cmd_line, (void *)rec->data, sizeof(cmd_line));
break;
case BI_SYSMAP:
sysmap = __va(rec->data[0]);
......@@ -620,7 +620,7 @@ void __init setup_arch(char **cmdline_p)
init_mm.brk = klimit;
/* Save unparsed command line copy for /proc/cmdline */
strcpy(saved_command_line, cmd_line);
strlcpy(saved_command_line, cmd_line, sizeof(saved_command_line));
*cmdline_p = cmd_line;
/* set up the bootmem stuff with available memory */
......
......@@ -104,7 +104,8 @@ struct machdep_calls {
};
extern struct machdep_calls ppc_md;
extern char cmd_line[512];
#define COMMAND_LINE_SIZE 512
extern char cmd_line[COMMAND_LINE_SIZE];
extern void setup_pci_ptrs(void);
......
......@@ -109,7 +109,8 @@ struct machdep_calls {
};
extern struct machdep_calls ppc_md;
extern char cmd_line[512];
#define COMMAND_LINE_SIZE 512
extern char cmd_line[COMMAND_LINE_SIZE];
/* Functions to produce codes on the leds.
* The SRC code should be unique for the message category and should
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment