mirror of
https://github.com/moparisthebest/curl
synced 2024-12-22 08:08:50 -05:00
changed the glob_url() call, after Janne Johansson's buffer overflow report
This commit is contained in:
parent
fac113a275
commit
b64dd9c13f
@ -965,8 +965,12 @@ int main(int argc, char *argv[])
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef GLOBURL
|
#ifdef GLOBURL
|
||||||
urlnum = glob_url(&urls, url); /* expand '{...}' and '[...]' expressions and return
|
/* expand '{...}' and '[...]' expressions and return total number of URLs
|
||||||
total number of URLs in pattern set */
|
in pattern set */
|
||||||
|
res = glob_url(&urls, url, &urlnum);
|
||||||
|
if(res != URG_OK)
|
||||||
|
return res;
|
||||||
|
|
||||||
outfiles = config.outfile; /* save outfile pattern befor expansion */
|
outfiles = config.outfile; /* save outfile pattern befor expansion */
|
||||||
if (!outfiles && !config.remotefile && urlnum > 1) {
|
if (!outfiles && !config.remotefile && urlnum > 1) {
|
||||||
#ifdef CURL_SEPARATORS
|
#ifdef CURL_SEPARATORS
|
||||||
|
@ -204,17 +204,22 @@ int glob_word(char *pattern, int pos) {
|
|||||||
exit (URG_FAILED_INIT);
|
exit (URG_FAILED_INIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
int glob_url(URLGlob** glob, char* url) {
|
int glob_url(URLGlob** glob, char* url, int *urlnum)
|
||||||
int urlnum; /* counts instances of a globbed pattern */
|
{
|
||||||
|
if (strlen(url)>URL_MAX_LENGTH) {
|
||||||
|
printf("Illegally sized URL\n");
|
||||||
|
return URG_URL_MALFORMAT;
|
||||||
|
}
|
||||||
|
|
||||||
glob_expand = (URLGlob*)malloc(sizeof(URLGlob));
|
glob_expand = (URLGlob*)malloc(sizeof(URLGlob));
|
||||||
glob_expand->size = 0;
|
glob_expand->size = 0;
|
||||||
urlnum = glob_word(url, 1);
|
*urlnum = glob_word(url, 1);
|
||||||
*glob = glob_expand;
|
*glob = glob_expand;
|
||||||
return urlnum;
|
return URG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *next_url(URLGlob *glob) {
|
char *next_url(URLGlob *glob)
|
||||||
|
{
|
||||||
static int beenhere = 0;
|
static int beenhere = 0;
|
||||||
char *buf = glob_buffer;
|
char *buf = glob_buffer;
|
||||||
URLPattern *pat;
|
URLPattern *pat;
|
||||||
|
@ -67,7 +67,7 @@ typedef struct {
|
|||||||
int size;
|
int size;
|
||||||
} URLGlob;
|
} URLGlob;
|
||||||
|
|
||||||
int glob_url(URLGlob**, char*);
|
int glob_url(URLGlob**, char*, int *);
|
||||||
char* next_url(URLGlob*);
|
char* next_url(URLGlob*);
|
||||||
char* match_url(char*, URLGlob);
|
char* match_url(char*, URLGlob);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user