005-istream_helpers-Fix-sscanf-typo.patch 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. From 7f6dd860818512c0eb313320308b22ba7e2c7205 Mon Sep 17 00:00:00 2001
  2. From: Rosen Penev <rosenp@gmail.com>
  3. Date: Fri, 4 Oct 2019 20:06:53 -0700
  4. Subject: [PATCH] istream_helpers: Fix sscanf typo
  5. This caused readin not to work properly with long long types.
  6. Found accidentally through a glibc warning
  7. (declared with warn_unused_result).
  8. Tested with gptfdisk on OpenWrt.
  9. Signed-off-by: Rosen Penev <rosenp@gmail.com>
  10. ---
  11. include/istream_helpers | 4 ++--
  12. 1 file changed, 2 insertions(+), 2 deletions(-)
  13. --- a/include/istream_helpers
  14. +++ b/include/istream_helpers
  15. @@ -317,7 +317,7 @@ namespace std{
  16. sscanf(temp.c_str(), "%llo", (unsigned long long *)&var );
  17. }else if(stream.flags() & ios_base::hex){
  18. if(stream.flags() & ios_base::uppercase){
  19. - scanf(temp.c_str(), "%llX", (unsigned long long *)&var );
  20. + sscanf(temp.c_str(), "%llX", (unsigned long long *)&var );
  21. }else{
  22. sscanf(temp.c_str(), "%llx", (unsigned long long *)&var);
  23. }
  24. @@ -344,7 +344,7 @@ namespace std{
  25. sscanf(temp.c_str(), "%llo", &var );
  26. }else if(stream.flags() & ios_base::hex){
  27. if(stream.flags() & ios_base::uppercase){
  28. - scanf(temp.c_str(), "%llX", &var );
  29. + sscanf(temp.c_str(), "%llX", &var );
  30. }else{
  31. sscanf(temp.c_str(), "%llx", &var);
  32. }