Jelajahi Sumber

lm32: avoid buffer overrun

Actually do what the comment says, using pstrcpy NUL-terminate:
strncpy does not always do that.

Signed-off-by: Jim Meyering <meyering@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Jim Meyering 13 tahun lalu
induk
melakukan
1044dc1118
1 mengubah file dengan 1 tambahan dan 1 penghapusan
  1. 1 1
      hw/lm32_hwsetup.h

+ 1 - 1
hw/lm32_hwsetup.h

@@ -96,7 +96,7 @@ static inline void hwsetup_add_tag(HWSetup *hw, enum hwsetup_tag t)
 
 
 static inline void hwsetup_add_str(HWSetup *hw, const char *str)
 static inline void hwsetup_add_str(HWSetup *hw, const char *str)
 {
 {
-    strncpy(hw->ptr, str, 31); /* make sure last byte is zero */
+    pstrcpy(hw->ptr, 32, str);
     hw->ptr += 32;
     hw->ptr += 32;
 }
 }