5K array on the stack is a big hefty, it is now allocated with malloc

instead
This commit is contained in:
Daniel Stenberg 2004-06-30 12:05:07 +00:00
parent 8efa6f407d
commit ce945bd2f0

View File

@ -638,17 +638,15 @@ struct CookieInfo *Curl_cookie_init(struct SessionHandle *data,
struct CookieInfo *inc, struct CookieInfo *inc,
bool newsession) bool newsession)
{ {
char line[MAX_COOKIE_LINE];
struct CookieInfo *c; struct CookieInfo *c;
FILE *fp; FILE *fp;
bool fromfile=TRUE; bool fromfile=TRUE;
if(NULL == inc) { if(NULL == inc) {
/* we didn't get a struct, create one */ /* we didn't get a struct, create one */
c = (struct CookieInfo *)malloc(sizeof(struct CookieInfo)); c = (struct CookieInfo *)calloc(1, sizeof(struct CookieInfo));
if(!c) if(!c)
return NULL; /* failed to get memory */ return NULL; /* failed to get memory */
memset(c, 0, sizeof(struct CookieInfo));
c->filename = strdup(file?file:"none"); /* copy the name just in case */ c->filename = strdup(file?file:"none"); /* copy the name just in case */
} }
else { else {
@ -669,6 +667,9 @@ struct CookieInfo *Curl_cookie_init(struct SessionHandle *data,
if(fp) { if(fp) {
char *lineptr; char *lineptr;
bool headerline; bool headerline;
char *line = (char *)malloc(MAX_COOKIE_LINE);
if(line) {
while(fgets(line, MAX_COOKIE_LINE, fp)) { while(fgets(line, MAX_COOKIE_LINE, fp)) {
if(checkprefix("Set-Cookie:", line)) { if(checkprefix("Set-Cookie:", line)) {
/* This is a cookie line, get it! */ /* This is a cookie line, get it! */
@ -684,6 +685,8 @@ struct CookieInfo *Curl_cookie_init(struct SessionHandle *data,
Curl_cookie_add(data, c, headerline, lineptr, NULL, NULL); Curl_cookie_add(data, c, headerline, lineptr, NULL, NULL);
} }
free(line); /* free the line buffer */
}
if(fromfile) if(fromfile)
fclose(fp); fclose(fp);
} }