One offender I own has:
STORAGE DEVICE  
1404x05xe3x07QGENEx00%x00x00x00x00x00x00x00x00x00x00x00x00x170x04

I limited it to pure ASCII only, but you might want to allow high-bit bytes,
either validating UTF-8 or assuming that mojibake is not as bad as beep and
zeroes as in the above example.  Or, cutting off at the first control
character might be a good alternative too.

Signed-off-by: Adam Borowski <kilob...@angband.pl>
---
 lib/libf2fs.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/libf2fs.c b/lib/libf2fs.c
index 5ef0214..8782afc 100644
--- a/lib/libf2fs.c
+++ b/lib/libf2fs.c
@@ -884,8 +884,9 @@ int get_device_info(int i)
 
                        MSG(0, "Info: [%s] Disk Model: ",
                                        dev->path);
-                       while (reply_buffer[i] != '`' && i < 80)
-                               printf("%c", reply_buffer[i++]);
+                       for (; reply_buffer[i] != '`' && i < 80; i++)
+                               printf((reply_buffer[i] >= ' ' && 
reply_buffer[i] < 127) ?
+                                      "%c" : "x%02x", reply_buffer[i]);
                        printf("\n");
                }
 #endif
-- 
2.17.0


------------------------------------------------------------------------------
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