This patch avoids to print garbage data.

Signed-off-by: Jaegeuk Kim <jaeg...@kernel.org>
---
 lib/libf2fs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/libf2fs.c b/lib/libf2fs.c
index d3311ca..63cf6d4 100644
--- a/lib/libf2fs.c
+++ b/lib/libf2fs.c
@@ -658,7 +658,7 @@ int f2fs_get_device_info(void)
        struct hd_geometry geom;
 #ifndef WITH_ANDROID
        sg_io_hdr_t io_hdr;
-       unsigned char reply_buffer[96];
+       unsigned char reply_buffer[96] = {0};
        unsigned char model_inq[6] = {MODELINQUIRY};
 #endif
        u_int64_t wanted_total_sectors = c.total_sectors;
@@ -725,7 +725,7 @@ int f2fs_get_device_info(void)
                        int i = 16;
 
                        MSG(0, "Info: Disk Model: ");
-                       while (reply_buffer[i] != '`')
+                       while (reply_buffer[i] != '`' && i < 80)
                                printf("%c", reply_buffer[i++]);
                        printf("\n");
                }
-- 
2.8.3


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reply via email to