Open buelowp opened 1 year ago
I just ran into the same problem and found this ticket by googling. Thanks for creating it.
@buelowp, I think your patch is close, but it will print a lot of error messages. snprintf
returns the number of bytes written, so the error message will happen whenever a nonzero number of bytes were written. (Which is probably usually true.)
I modified my copy slightly to check if ret > 4
.
Cheers! Thanks for the patch
Thnx for the fix!
What do you think about this alternative solution: https://github.com/martinSusz/rkdeveloptool/commit/1e6322cafb6e7d5b08c0427e890fa6bc89a535e2 ?
I'm a noob in the blind trying to solve this issue. How do I actually run this patch?
I've tried entering the rkdeveloptool folder and pasting the whole thing in the terminal but get a "zsh: parse error near `}'". Am I on the right track at all?
Would also love to know how to apply this
So the above solution is not a command to run, but is showing the Git Diff between the original main.cpp file, and the patched version (More on reading these diffs here: https://www.atlassian.com/git/tutorials/saving-changes/git-diff)
Essentially, you want to open the main.cpp file, find the lines referenced above, remove the lines that have -- prefix, and add in the new lines that have the ++prefix. Then save and try run 👍
diff --git a/main.cpp b/main.cpp
index 72bd94b..ec5257b 100644
--- a/main.cpp
+++ b/main.cpp
@@ -1489,8 +1489,12 @@ static bool saveEntry(FILE* outFile, char* path, rk_entry_type type,
static inline uint32_t convertChipType(const char* chip) {
char buffer[5];
+ int ret = 0;
+
memset(buffer, 0, sizeof(buffer));
- snprintf(buffer, sizeof(buffer), "%s", chip);
+ if ((ret = snprintf(buffer, sizeof(buffer), "%s", chip)) > 4) {
+ perror("snprintf");
+ }
return buffer[0] << 24 | buffer[1] << 16 | buffer[2] << 8 | buffer[3];
}
Copy this into a file called snprintf.patch and save it to the same folder as main.cpp. Then, run patch -p0 < snprintf.patch. I can't really get into the details of how to use patch or patch for Windows here, there are a LOT of google results to help with that. However, that short workflow will apply the patch.
Then you must build it, and once built, you can use it.
Later versions of GCC have started to generate the warning
and because -Wall and -Werror are used, this causes the build to fail. I've attached the patch I used, but there may be a better solution.