mirror of
https://github.com/moparisthebest/curl
synced 2024-11-10 19:45:04 -05:00
bail out if we can't allocate the new range string, and make use of aprintf()
instead of using snprintf() + strdup().
This commit is contained in:
parent
34af02caca
commit
d301d69fbf
15
lib/url.c
15
lib/url.c
@ -2036,7 +2036,6 @@ static CURLcode CreateConnection(struct SessionHandle *data,
|
|||||||
{
|
{
|
||||||
char *tmp;
|
char *tmp;
|
||||||
CURLcode result=CURLE_OK;
|
CURLcode result=CURLE_OK;
|
||||||
char resumerange[40]="";
|
|
||||||
struct connectdata *conn;
|
struct connectdata *conn;
|
||||||
struct connectdata *conn_temp;
|
struct connectdata *conn_temp;
|
||||||
int urllen;
|
int urllen;
|
||||||
@ -2484,9 +2483,9 @@ static CURLcode CreateConnection(struct SessionHandle *data,
|
|||||||
if(conn->resume_from) {
|
if(conn->resume_from) {
|
||||||
if(!conn->bits.use_range) {
|
if(!conn->bits.use_range) {
|
||||||
/* if it already was in use, we just skip this */
|
/* if it already was in use, we just skip this */
|
||||||
snprintf(resumerange, sizeof(resumerange), "%" FORMAT_OFF_T "-",
|
conn->range = aprintf("%" FORMAT_OFF_T "-", conn->resume_from);
|
||||||
conn->resume_from);
|
if(!conn->range)
|
||||||
conn->range=strdup(resumerange); /* tell ourselves to fetch this range */
|
return CURLE_OUT_OF_MEMORY;
|
||||||
conn->bits.rangestringalloc = TRUE; /* mark as allocated */
|
conn->bits.rangestringalloc = TRUE; /* mark as allocated */
|
||||||
conn->bits.use_range = 1; /* switch on range usage */
|
conn->bits.use_range = 1; /* switch on range usage */
|
||||||
}
|
}
|
||||||
@ -3004,19 +3003,21 @@ static CURLcode CreateConnection(struct SessionHandle *data,
|
|||||||
*/
|
*/
|
||||||
conn->resume_from = data->set.set_resume_from;
|
conn->resume_from = data->set.set_resume_from;
|
||||||
if (conn->resume_from) {
|
if (conn->resume_from) {
|
||||||
snprintf(resumerange, sizeof(resumerange), "%" FORMAT_OFF_T "-",
|
|
||||||
conn->resume_from);
|
|
||||||
if (conn->bits.rangestringalloc == TRUE)
|
if (conn->bits.rangestringalloc == TRUE)
|
||||||
free(conn->range);
|
free(conn->range);
|
||||||
|
conn->range = aprintf("%" FORMAT_OFF_T "-", conn->resume_from);
|
||||||
|
if(!conn->range)
|
||||||
|
return CURLE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
/* tell ourselves to fetch this range */
|
/* tell ourselves to fetch this range */
|
||||||
conn->range = strdup(resumerange);
|
|
||||||
conn->bits.use_range = TRUE; /* enable range download */
|
conn->bits.use_range = TRUE; /* enable range download */
|
||||||
conn->bits.rangestringalloc = TRUE; /* mark range string allocated */
|
conn->bits.rangestringalloc = TRUE; /* mark range string allocated */
|
||||||
}
|
}
|
||||||
else if (data->set.set_range) {
|
else if (data->set.set_range) {
|
||||||
/* There is a range, but is not a resume, useful for random ftp access */
|
/* There is a range, but is not a resume, useful for random ftp access */
|
||||||
conn->range = strdup(data->set.set_range);
|
conn->range = strdup(data->set.set_range);
|
||||||
|
if(!conn->range)
|
||||||
|
return CURLE_OUT_OF_MEMORY;
|
||||||
conn->bits.rangestringalloc = TRUE; /* mark range string allocated */
|
conn->bits.rangestringalloc = TRUE; /* mark range string allocated */
|
||||||
conn->bits.use_range = TRUE; /* enable range download */
|
conn->bits.use_range = TRUE; /* enable range download */
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user