[PATCH] arch/sparc: additional len check in loop for prom_getbootargs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



  when cp >= barg_buf + BARG_LEN-2, it only break internel loop (while)
  but outside loop (for) still has effect, and "*cp++ = ' '" repeating
  so need additional checking for it.


Signed-off-by: Chen Gang <gang.chen@xxxxxxxxxxx>
---
 arch/sparc/prom/bootstr_32.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/sparc/prom/bootstr_32.c b/arch/sparc/prom/bootstr_32.c
index f5ec32e..25cda1c 100644
--- a/arch/sparc/prom/bootstr_32.c
+++ b/arch/sparc/prom/bootstr_32.c
@@ -40,6 +40,10 @@ prom_getbootargs(void)
 				*cp++ = *arg++;
 			}
 			*cp++ = ' ';
+			if(cp >= barg_buf + BARG_LEN-1){
+				/* We might issue a warning here. */
+				break;
+			}
 		}
 		*cp = 0;
 		break;
-- 
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Kernel Development]     [DCCP]     [Linux ARM Development]     [Linux]     [Photo]     [Yosemite Help]     [Linux ARM Kernel]     [Linux SCSI]     [Linux x86_64]     [Linux Hams]

  Powered by Linux