diff options
author | Maxim Yurchuk <maxim-yurchuk@ydb.tech> | 2024-10-18 20:31:38 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-18 20:31:38 +0300 |
commit | 2a74bac2d2d3bccb4e10120f1ead805640ec9dd0 (patch) | |
tree | 047e4818ced5aaf73f58517629e5260b5291f9f0 /contrib/libs/curl/lib/netrc.c | |
parent | 2d9656823e9521d8c29ea4c9a1d0eab78391abfc (diff) | |
parent | 3d834a1923bbf9403cd4a448e7f32b670aa4124f (diff) | |
download | ydb-2a74bac2d2d3bccb4e10120f1ead805640ec9dd0.tar.gz |
Merge pull request #10502 from ydb-platform/mergelibs-241016-1210
Library import 241016-1210
Diffstat (limited to 'contrib/libs/curl/lib/netrc.c')
-rw-r--r-- | contrib/libs/curl/lib/netrc.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/contrib/libs/curl/lib/netrc.c b/contrib/libs/curl/lib/netrc.c index 490efb64ca..038c6dca6a 100644 --- a/contrib/libs/curl/lib/netrc.c +++ b/contrib/libs/curl/lib/netrc.c @@ -53,8 +53,6 @@ enum host_lookup_state { #define NETRC_FAILED -1 #define NETRC_SUCCESS 0 -#define MAX_NETRC_LINE 4096 - /* * Returns zero on success. */ @@ -82,14 +80,13 @@ static int parsenetrc(const char *host, file = fopen(netrcfile, FOPEN_READTEXT); if(file) { bool done = FALSE; - struct dynbuf buf; - Curl_dyn_init(&buf, MAX_NETRC_LINE); + char netrcbuffer[4096]; + int netrcbuffsize = (int)sizeof(netrcbuffer); - while(!done && Curl_get_line(&buf, file)) { + while(!done && Curl_get_line(netrcbuffer, netrcbuffsize, file)) { char *tok; char *tok_end; bool quoted; - char *netrcbuffer = Curl_dyn_ptr(&buf); if(state == MACDEF) { if((netrcbuffer[0] == '\n') || (netrcbuffer[0] == '\r')) state = NOTHING; @@ -237,7 +234,7 @@ static int parsenetrc(const char *host, else if(strcasecompare("password", tok)) state_password = 1; else if(strcasecompare("machine", tok)) { - /* ok, there is machine here go => */ + /* ok, there's machine here go => */ state = HOSTFOUND; state_our_login = FALSE; } @@ -248,7 +245,6 @@ static int parsenetrc(const char *host, } /* while Curl_get_line() */ out: - Curl_dyn_free(&buf); if(!retcode) { /* success */ if(login_alloc) { @@ -277,7 +273,7 @@ out: /* * @unittest: 1304 * - * *loginp and *passwordp MUST be allocated if they are not NULL when passed + * *loginp and *passwordp MUST be allocated if they aren't NULL when passed * in. */ int Curl_parsenetrc(const char *host, char **loginp, char **passwordp, @@ -324,7 +320,7 @@ int Curl_parsenetrc(const char *host, char **loginp, char **passwordp, return retcode; /* no home directory found (or possibly out of memory) */ - filealloc = aprintf("%s%s.netrc", home, DIR_CHAR); + filealloc = curl_maprintf("%s%s.netrc", home, DIR_CHAR); if(!filealloc) { free(homea); return -1; @@ -334,7 +330,7 @@ int Curl_parsenetrc(const char *host, char **loginp, char **passwordp, #ifdef _WIN32 if(retcode == NETRC_FILE_MISSING) { /* fallback to the old-style "_netrc" file */ - filealloc = aprintf("%s%s_netrc", home, DIR_CHAR); + filealloc = curl_maprintf("%s%s_netrc", home, DIR_CHAR); if(!filealloc) { free(homea); return -1; |