[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnurl] 160/411: --help: strdup the category
From: |
gnunet |
Subject: |
[gnurl] 160/411: --help: strdup the category |
Date: |
Wed, 13 Jan 2021 01:19:35 +0100 |
This is an automated email from the git hooks/post-receive script.
nikita pushed a commit to branch master
in repository gnurl.
commit 5bd63e0619d10d81850a9993ac278396bb77e36c
Author: Daniel Stenberg <daniel@haxx.se>
AuthorDate: Fri Sep 18 08:09:09 2020 +0200
--help: strdup the category
... since it is converted and the original pointer is freed on Windows
unicode handling.
Follow-up to aa8777f63febc
Fixes #5977
Closes #5978
Reported-by: xwxbug on github
---
src/tool_getparam.c | 6 +++++-
src/tool_help.c | 20 ++++++++------------
src/tool_help.h | 2 +-
3 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/src/tool_getparam.c b/src/tool_getparam.c
index a884f4b38..7977c3dc6 100644
--- a/src/tool_getparam.c
+++ b/src/tool_getparam.c
@@ -1777,7 +1777,11 @@ ParameterError getparameter(const char *flag, /* f or
-long-flag */
case 'h': /* h for help */
if(toggle) {
- global->help_category = nextarg;
+ if(nextarg) {
+ global->help_category = strdup(nextarg);
+ if(!global->help_category)
+ return PARAM_NO_MEM;
+ }
return PARAM_HELP_REQUESTED;
}
/* we now actually support --no-help too! */
diff --git a/src/tool_help.c b/src/tool_help.c
index 54a37e6b2..a67e4bc85 100644
--- a/src/tool_help.c
+++ b/src/tool_help.c
@@ -899,35 +899,31 @@ static void get_categories(void)
}
-void tool_help(const char *category)
+void tool_help(char *category)
{
puts("Usage: curl [options...] <url>");
/* If no category was provided */
if(!category) {
const char *category_note = "\nThis is not the full help, this "
- "menu is stripped into categories.\nUse \"--help category\" to get "
- "an overview of all categories.\nFor all options use the manual"
- " or \"--help all\".";
+ "menu is stripped into categories.\nUse \"--help category\" to get "
+ "an overview of all categories.\nFor all options use the manual"
+ " or \"--help all\".";
print_category(CURLHELP_IMPORTANT);
puts(category_note);
- return;
}
/* Lets print everything if "all" was provided */
- if(curl_strequal(category, "all")) {
+ else if(curl_strequal(category, "all"))
/* Print everything except hidden */
print_category(~(CURLHELP_HIDDEN));
- return;
- }
/* Lets handle the string "category" differently to not print an errormsg */
- if(curl_strequal(category, "category")) {
+ else if(curl_strequal(category, "category"))
get_categories();
- return;
- }
/* Otherwise print category and handle the case if the cat was not found */
- if(get_category_content(category)) {
+ else if(get_category_content(category)) {
puts("Invalid category provided, here is a list of all categories:\n");
get_categories();
}
+ free(category);
}
static int
diff --git a/src/tool_help.h b/src/tool_help.h
index 536ac10f8..1da23cc54 100644
--- a/src/tool_help.h
+++ b/src/tool_help.h
@@ -23,7 +23,7 @@
***************************************************************************/
#include "tool_setup.h"
-void tool_help(const char *category);
+void tool_help(char *category);
void tool_list_engines(void);
void tool_version_info(void);
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [gnurl] 167/411: parsedate: tune the date to epoch conversion, (continued)
- [gnurl] 167/411: parsedate: tune the date to epoch conversion, gnunet, 2021/01/12
- [gnurl] 146/411: tool_help.h: update copyright year range, gnunet, 2021/01/12
- [gnurl] 164/411: docs/MQTT: not experimental anymore, gnunet, 2021/01/12
- [gnurl] 178/411: dynbuf: make *addf() not require extra mallocs, gnunet, 2021/01/12
- [gnurl] 157/411: ftp: avoid risk of reading uninitialized integers, gnunet, 2021/01/12
- [gnurl] 170/411: setopt: return CURLE_BAD_FUNCTION_ARGUMENT on bad argument, gnunet, 2021/01/12
- [gnurl] 185/411: strerror: honor Unicode API choice on Windows, gnunet, 2021/01/12
- [gnurl] 176/411: pingpong: remove a malloc per Curl_pp_vsendf call, gnunet, 2021/01/12
- [gnurl] 125/411: dynbuf: make sure Curl_dyn_tail() zero terminates, gnunet, 2021/01/12
- [gnurl] 144/411: tool_writeout: protect fputs() from NULL, gnunet, 2021/01/12
- [gnurl] 160/411: --help: strdup the category,
gnunet <=
- [gnurl] 165/411: docs/MQTT: remove outdated paaragraphs, gnunet, 2021/01/12
- [gnurl] 175/411: symbian: drop support, gnunet, 2021/01/12
- [gnurl] 152/411: github: use new issue template feature, gnunet, 2021/01/12
- [gnurl] 171/411: http_proxy: do not count proxy headers in the header bytecount, gnunet, 2021/01/12
- [gnurl] 166/411: cmake: remove scary warning, gnunet, 2021/01/12
- [gnurl] 151/411: urlapi: use more Curl_safefree, gnunet, 2021/01/12
- [gnurl] 135/411: curl: make checkpasswd use dynbuf, gnunet, 2021/01/12
- [gnurl] 77/411: llist: make it "struct Curl_llist", gnunet, 2021/01/12
- [gnurl] 186/411: ngtcp2: adapt to new NGTCP2_PROTO_VER_MAX define, gnunet, 2021/01/12
- [gnurl] 173/411: curl_krb5.h: rename from krb5.h, gnunet, 2021/01/12