[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnurl] 135/411: curl: make checkpasswd use dynbuf
From: |
gnunet |
Subject: |
[gnurl] 135/411: curl: make checkpasswd use dynbuf |
Date: |
Wed, 13 Jan 2021 01:19:10 +0100 |
This is an automated email from the git hooks/post-receive script.
nikita pushed a commit to branch master
in repository gnurl.
commit a1679498481de5b83532042d1b5bbd269b277a82
Author: Daniel Stenberg <daniel@haxx.se>
AuthorDate: Fri Sep 11 11:20:07 2020 +0200
curl: make checkpasswd use dynbuf
Closes #5952
---
src/tool_paramhlp.c | 23 ++++++++---------------
1 file changed, 8 insertions(+), 15 deletions(-)
diff --git a/src/tool_paramhlp.c b/src/tool_paramhlp.c
index 84d7321bf..03cd44fee 100644
--- a/src/tool_paramhlp.c
+++ b/src/tool_paramhlp.c
@@ -413,6 +413,7 @@ ParameterError str2offset(curl_off_t *val, const char *str)
return PARAM_BAD_NUMERIC;
}
+#define MAX_USERPWDLENGTH (100*1024)
static CURLcode checkpasswd(const char *kind, /* for what purpose */
const size_t i, /* operation index */
const bool last, /* TRUE if last operation */
@@ -432,12 +433,11 @@ static CURLcode checkpasswd(const char *kind, /* for what
purpose */
if(!psep && **userpwd != ';') {
/* no password present, prompt for one */
- char passwd[256] = "";
+ char passwd[2048] = "";
char prompt[256];
- size_t passwdlen;
- size_t userlen = strlen(*userpwd);
- char *passptr;
+ struct curlx_dynbuf dyn;
+ curlx_dyn_init(&dyn, MAX_USERPWDLENGTH);
if(osep)
*osep = '\0';
@@ -453,22 +453,15 @@ static CURLcode checkpasswd(const char *kind, /* for what
purpose */
/* get password */
getpass_r(prompt, passwd, sizeof(passwd));
- passwdlen = strlen(passwd);
-
if(osep)
*osep = ';';
- /* extend the allocated memory area to fit the password too */
- passptr = realloc(*userpwd,
- passwdlen + 1 + /* an extra for the colon */
- userlen + 1); /* an extra for the zero */
- if(!passptr)
+ if(curlx_dyn_addf(&dyn, "%s:%s", *userpwd, passwd))
return CURLE_OUT_OF_MEMORY;
- /* append the password separated with a colon */
- passptr[userlen] = ':';
- memcpy(&passptr[userlen + 1], passwd, passwdlen + 1);
- *userpwd = passptr;
+ /* return the new string */
+ free(*userpwd);
+ *userpwd = curlx_dyn_ptr(&dyn);
}
return CURLE_OK;
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [gnurl] 176/411: pingpong: remove a malloc per Curl_pp_vsendf call, (continued)
- [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, 2021/01/12
- [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 <=
- [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
- [gnurl] 127/411: curl: use curlx_dynbuf for realloc when loading config files, gnunet, 2021/01/12
- [gnurl] 129/411: test434: test -K use in a single line without newline, gnunet, 2021/01/12
- [gnurl] 184/411: imap: make imap_send use dynbuf for the send buffer management, gnunet, 2021/01/12
- [gnurl] 161/411: BUGS: convert document to markdown, gnunet, 2021/01/12
- [gnurl] 174/411: RELEASE-NOTES: synced, gnunet, 2021/01/12
- [gnurl] 168/411: Curl_handler: add 'family' to each protocol, gnunet, 2021/01/12
- [gnurl] 141/411: tests/FILEFORMAT: document type=shell for <command>, gnunet, 2021/01/12