From: <abe...@us...> - 2017-02-06 13:27:29
|
Revision: 8150 http://sourceforge.net/p/astlinux/code/8150 Author: abelbeck Date: 2017-02-06 13:27:26 +0000 (Mon, 06 Feb 2017) Log Message: ----------- sngrep, Use sng_malloc() for rcfile string buffers instead of fixed stack based buffers Ref: https://github.com/irontec/sngrep/commit/04fa090b91533cf48f22aab31f9c0078a5d492fc Added Paths: ----------- branches/1.0/package/sngrep/sngrep-0003-upstream-getenv-malloc.patch branches/1.0/package/sngrep/sngrep-0004-upstream-silence-clang-warnings.patch Added: branches/1.0/package/sngrep/sngrep-0003-upstream-getenv-malloc.patch =================================================================== --- branches/1.0/package/sngrep/sngrep-0003-upstream-getenv-malloc.patch (rev 0) +++ branches/1.0/package/sngrep/sngrep-0003-upstream-getenv-malloc.patch 2017-02-06 13:27:26 UTC (rev 8150) @@ -0,0 +1,169 @@ +diff --git a/src/curses/ui_column_select.c b/src/curses/ui_column_select.c +index 86d7ba1..d76be47 100644 +--- a/src/curses/ui_column_select.c ++++ b/src/curses/ui_column_select.c +@@ -374,15 +374,34 @@ column_select_save_columns(ui_t *ui) + char columnopt[128]; + char line[1024]; + char *rcfile; +- char userconf[128], tmpfile[128]; ++ char *userconf = NULL; ++ char *tmpfile = NULL; + + // Use current $SNGREPRC or $HOME/.sngreprc file + if (rcfile = getenv("SNGREPRC")) { +- sprintf(userconf, "%s", rcfile); +- sprintf(tmpfile, "%s.old", rcfile); ++ if (userconf = sng_malloc(strlen(rcfile) + RCFILE_EXTRA_LEN)) { ++ if (tmpfile = sng_malloc(strlen(rcfile) + RCFILE_EXTRA_LEN)) { ++ sprintf(userconf, "%s", rcfile); ++ sprintf(tmpfile, "%s.old", rcfile); ++ } else { ++ sng_free(userconf); ++ return; ++ } ++ } else { ++ return; ++ } + } else if (rcfile = getenv("HOME")) { +- sprintf(userconf, "%s/.sngreprc", rcfile); +- sprintf(tmpfile, "%s/.sngreprc.old", rcfile); ++ if (userconf = sng_malloc(strlen(rcfile) + RCFILE_EXTRA_LEN)) { ++ if (tmpfile = sng_malloc(strlen(rcfile) + RCFILE_EXTRA_LEN)) { ++ sprintf(userconf, "%s/.sngreprc", rcfile); ++ sprintf(tmpfile, "%s/.sngreprc.old", rcfile); ++ } else { ++ sng_free(userconf); ++ return; ++ } ++ } else { ++ return; ++ } + } else { + return; + } +@@ -396,6 +415,8 @@ column_select_save_columns(ui_t *ui) + // Create a new user conf file + if (!(fo = fopen(userconf, "w"))) { + dialog_run("Unable to open %s: %s", userconf, strerror(errno)); ++ sng_free(userconf); ++ sng_free(tmpfile); + return; + } + +@@ -430,6 +451,9 @@ column_select_save_columns(ui_t *ui) + + // Show a information dialog + dialog_run("Column layout successfully saved to %s", userconf); ++ ++ sng_free(userconf); ++ sng_free(tmpfile); + } + + +diff --git a/src/curses/ui_settings.c b/src/curses/ui_settings.c +index 48c9f11..2c7fe39 100644 +--- a/src/curses/ui_settings.c ++++ b/src/curses/ui_settings.c +@@ -453,7 +453,8 @@ ui_settings_save(ui_t *ui) + FILE *fi, *fo; + char line[1024]; + char *rcfile; +- char userconf[128], tmpfile[128]; ++ char *userconf = NULL; ++ char *tmpfile = NULL; + char field_value[180]; + settings_entry_t *entry; + +@@ -462,11 +463,29 @@ ui_settings_save(ui_t *ui) + + // Use current $SNGREPRC or $HOME/.sngreprc file + if (rcfile = getenv("SNGREPRC")) { +- sprintf(userconf, "%s", rcfile); +- sprintf(tmpfile, "%s.old", rcfile); ++ if (userconf = sng_malloc(strlen(rcfile) + RCFILE_EXTRA_LEN)) { ++ if (tmpfile = sng_malloc(strlen(rcfile) + RCFILE_EXTRA_LEN)) { ++ sprintf(userconf, "%s", rcfile); ++ sprintf(tmpfile, "%s.old", rcfile); ++ } else { ++ sng_free(userconf); ++ return; ++ } ++ } else { ++ return; ++ } + } else if (rcfile = getenv("HOME")) { +- sprintf(userconf, "%s/.sngreprc", rcfile); +- sprintf(tmpfile, "%s/.sngreprc.old", rcfile); ++ if (userconf = sng_malloc(strlen(rcfile) + RCFILE_EXTRA_LEN)) { ++ if (tmpfile = sng_malloc(strlen(rcfile) + RCFILE_EXTRA_LEN)) { ++ sprintf(userconf, "%s/.sngreprc", rcfile); ++ sprintf(tmpfile, "%s/.sngreprc.old", rcfile); ++ } else { ++ sng_free(userconf); ++ return; ++ } ++ } else { ++ return; ++ } + } else { + dialog_run("Unable to save configuration. User has no $SNGREPRC or $HOME dir."); + return; +@@ -480,6 +499,8 @@ ui_settings_save(ui_t *ui) + + // Create a new user conf file + if (!(fo = fopen(userconf, "w"))) { ++ sng_free(userconf); ++ sng_free(tmpfile); + return; + } + +@@ -510,4 +531,7 @@ ui_settings_save(ui_t *ui) + fclose(fo); + + dialog_run("Settings successfully saved to %s", userconf); ++ ++ sng_free(userconf); ++ sng_free(tmpfile); + } +diff --git a/src/option.c b/src/option.c +index b1efa08..641321a 100644 +--- a/src/option.c ++++ b/src/option.c +@@ -50,7 +50,7 @@ int + init_options() + { + // Custom user conf file +- char userconf[128]; ++ char *userconf = NULL; + char *rcfile; + char pwd[MAX_SETTING_LEN]; + +@@ -79,8 +79,11 @@ init_options() + if (rcfile = getenv("SNGREPRC")) { + read_options(rcfile); + } else if (rcfile = getenv("HOME")) { +- sprintf(userconf, "%s/.sngreprc", rcfile); +- read_options(userconf); ++ if (userconf = sng_malloc(strlen(rcfile) + RCFILE_EXTRA_LEN)) { ++ sprintf(userconf, "%s/.sngreprc", rcfile); ++ read_options(userconf); ++ sng_free(userconf); ++ } + } + + return 0; +diff --git a/src/setting.h b/src/setting.h +index 20c197c..65d7341 100644 +--- a/src/setting.h ++++ b/src/setting.h +@@ -45,6 +45,9 @@ + //! Max setting value + #define MAX_SETTING_LEN 1024 + ++//! Max extra length needed for "/.sngreprc.old" ++#define RCFILE_EXTRA_LEN 16 ++ + //! Shorter declarartion of setting_option struct + typedef struct setting_option setting_t; + Added: branches/1.0/package/sngrep/sngrep-0004-upstream-silence-clang-warnings.patch =================================================================== --- branches/1.0/package/sngrep/sngrep-0004-upstream-silence-clang-warnings.patch (rev 0) +++ branches/1.0/package/sngrep/sngrep-0004-upstream-silence-clang-warnings.patch 2017-02-06 13:27:26 UTC (rev 8150) @@ -0,0 +1,78 @@ +diff --git a/src/curses/ui_column_select.c b/src/curses/ui_column_select.c +index d76be47..7bc8e71 100644 +--- a/src/curses/ui_column_select.c ++++ b/src/curses/ui_column_select.c +@@ -378,9 +378,9 @@ column_select_save_columns(ui_t *ui) + char *tmpfile = NULL; + + // Use current $SNGREPRC or $HOME/.sngreprc file +- if (rcfile = getenv("SNGREPRC")) { +- if (userconf = sng_malloc(strlen(rcfile) + RCFILE_EXTRA_LEN)) { +- if (tmpfile = sng_malloc(strlen(rcfile) + RCFILE_EXTRA_LEN)) { ++ if ((rcfile = getenv("SNGREPRC"))) { ++ if ((userconf = sng_malloc(strlen(rcfile) + RCFILE_EXTRA_LEN))) { ++ if ((tmpfile = sng_malloc(strlen(rcfile) + RCFILE_EXTRA_LEN))) { + sprintf(userconf, "%s", rcfile); + sprintf(tmpfile, "%s.old", rcfile); + } else { +@@ -390,9 +390,9 @@ column_select_save_columns(ui_t *ui) + } else { + return; + } +- } else if (rcfile = getenv("HOME")) { +- if (userconf = sng_malloc(strlen(rcfile) + RCFILE_EXTRA_LEN)) { +- if (tmpfile = sng_malloc(strlen(rcfile) + RCFILE_EXTRA_LEN)) { ++ } else if ((rcfile = getenv("HOME"))) { ++ if ((userconf = sng_malloc(strlen(rcfile) + RCFILE_EXTRA_LEN))) { ++ if ((tmpfile = sng_malloc(strlen(rcfile) + RCFILE_EXTRA_LEN))) { + sprintf(userconf, "%s/.sngreprc", rcfile); + sprintf(tmpfile, "%s/.sngreprc.old", rcfile); + } else { +diff --git a/src/curses/ui_settings.c b/src/curses/ui_settings.c +index 2c7fe39..3aba988 100644 +--- a/src/curses/ui_settings.c ++++ b/src/curses/ui_settings.c +@@ -462,9 +462,9 @@ ui_settings_save(ui_t *ui) + settings_info_t *info = settings_info(ui); + + // Use current $SNGREPRC or $HOME/.sngreprc file +- if (rcfile = getenv("SNGREPRC")) { +- if (userconf = sng_malloc(strlen(rcfile) + RCFILE_EXTRA_LEN)) { +- if (tmpfile = sng_malloc(strlen(rcfile) + RCFILE_EXTRA_LEN)) { ++ if ((rcfile = getenv("SNGREPRC"))) { ++ if ((userconf = sng_malloc(strlen(rcfile) + RCFILE_EXTRA_LEN))) { ++ if ((tmpfile = sng_malloc(strlen(rcfile) + RCFILE_EXTRA_LEN))) { + sprintf(userconf, "%s", rcfile); + sprintf(tmpfile, "%s.old", rcfile); + } else { +@@ -474,9 +474,9 @@ ui_settings_save(ui_t *ui) + } else { + return; + } +- } else if (rcfile = getenv("HOME")) { +- if (userconf = sng_malloc(strlen(rcfile) + RCFILE_EXTRA_LEN)) { +- if (tmpfile = sng_malloc(strlen(rcfile) + RCFILE_EXTRA_LEN)) { ++ } else if ((rcfile = getenv("HOME"))) { ++ if ((userconf = sng_malloc(strlen(rcfile) + RCFILE_EXTRA_LEN))) { ++ if ((tmpfile = sng_malloc(strlen(rcfile) + RCFILE_EXTRA_LEN))) { + sprintf(userconf, "%s/.sngreprc", rcfile); + sprintf(tmpfile, "%s/.sngreprc.old", rcfile); + } else { +diff --git a/src/option.c b/src/option.c +index 641321a..77bdc3b 100644 +--- a/src/option.c ++++ b/src/option.c +@@ -76,10 +76,10 @@ init_options() + read_options("/etc/sngreprc"); + read_options("/usr/local/etc/sngreprc"); + // Get user configuration +- if (rcfile = getenv("SNGREPRC")) { ++ if ((rcfile = getenv("SNGREPRC"))) { + read_options(rcfile); +- } else if (rcfile = getenv("HOME")) { +- if (userconf = sng_malloc(strlen(rcfile) + RCFILE_EXTRA_LEN)) { ++ } else if ((rcfile = getenv("HOME"))) { ++ if ((userconf = sng_malloc(strlen(rcfile) + RCFILE_EXTRA_LEN))) { + sprintf(userconf, "%s/.sngreprc", rcfile); + read_options(userconf); + sng_free(userconf); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |