aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Keniston <jkenisto@us.ibm.com>2010-11-11 13:54:27 -0500
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2010-11-29 23:43:51 -0500
commit6024ede9ba84aa1b891c2d6bc98eda07801235e5 (patch)
treefa7a2c4c991ae4b5d3b083944394a4e0ecf02591
parent690d1a9bd14bd861328ca66473a223f60cf1ad31 (diff)
powerpc/nvram: Handle partition names >= 12 chars
The name field in the nvram_header can be < 12 chars, null-terminated, or 12 chars without the null. Handle this safely. Signed-off-by: Jim Keniston <jkenisto@us.ibm.com> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
-rw-r--r--arch/powerpc/kernel/nvram_64.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/arch/powerpc/kernel/nvram_64.c b/arch/powerpc/kernel/nvram_64.c
index b8a50fa5875b..bb12b3248f13 100644
--- a/arch/powerpc/kernel/nvram_64.c
+++ b/arch/powerpc/kernel/nvram_64.c
@@ -42,6 +42,7 @@ struct nvram_header {
42 unsigned char signature; 42 unsigned char signature;
43 unsigned char checksum; 43 unsigned char checksum;
44 unsigned short length; 44 unsigned short length;
45 /* Terminating null required only for names < 12 chars. */
45 char name[12]; 46 char name[12];
46}; 47};
47 48
@@ -201,7 +202,7 @@ static void __init nvram_print_partitions(char * label)
201 printk(KERN_WARNING "--------%s---------\n", label); 202 printk(KERN_WARNING "--------%s---------\n", label);
202 printk(KERN_WARNING "indx\t\tsig\tchks\tlen\tname\n"); 203 printk(KERN_WARNING "indx\t\tsig\tchks\tlen\tname\n");
203 list_for_each_entry(tmp_part, &nvram_partitions, partition) { 204 list_for_each_entry(tmp_part, &nvram_partitions, partition) {
204 printk(KERN_WARNING "%4d \t%02x\t%02x\t%d\t%s\n", 205 printk(KERN_WARNING "%4d \t%02x\t%02x\t%d\t%12s\n",
205 tmp_part->index, tmp_part->header.signature, 206 tmp_part->index, tmp_part->header.signature,
206 tmp_part->header.checksum, tmp_part->header.length, 207 tmp_part->header.checksum, tmp_part->header.length,
207 tmp_part->header.name); 208 tmp_part->header.name);
@@ -256,7 +257,7 @@ int __init nvram_remove_partition(const char *name, int sig)
256 257
257 /* Make partition a free partition */ 258 /* Make partition a free partition */
258 part->header.signature = NVRAM_SIG_FREE; 259 part->header.signature = NVRAM_SIG_FREE;
259 sprintf(part->header.name, "wwwwwwwwwwww"); 260 strncpy(part->header.name, "wwwwwwwwwwww", 12);
260 part->header.checksum = nvram_checksum(&part->header); 261 part->header.checksum = nvram_checksum(&part->header);
261 rc = nvram_write_header(part); 262 rc = nvram_write_header(part);
262 if (rc <= 0) { 263 if (rc <= 0) {