Closed Bug 105039 Opened 24 years ago Closed 24 years ago

set-cookie max-age field ignored

Categories

(Core :: Networking: Cookies, defect)

x86
Linux
defect
Not set
major

Tracking

()

RESOLVED FIXED
mozilla0.9.6

People

(Reporter: patrick, Assigned: morse)

References

()

Details

Attachments

(1 file, 2 obsolete files)

The Max-Age field in the Set-Cookie http header is ignored
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Target Milestone: --- → mozilla0.9.6
Attached patch process max-age field (obsolete) — Splinter Review
cc'ing alecf and sgehani for reviews
Comment on attachment 53775 [details] [diff] [review] process max-age field r=sgehani It would be nice to mention section 10.1.2 of RFC 2109 in the (first) comment about the expires attribute for other developer's reference.
Attachment #53775 - Flags: review+
ack, I must have been bitten by the bugzilla-IP address password thing What I meant to say was: isn't there a well-known way to convert strings to integers? looking at the code, it looks like we use atoi() all over the place, and I can't see any reason that it's inherently bad...
Alecf, The reason not to use atoi is that we have to first get the sequence to be null terminated. That would involve stepping through the string looking for a terminator (null or semicolon), saving the character at that termination position, replacing the character with a null, doing the atoi, and then restoring the original character. Since we have to step through the string anyway, it seems simpler to just exract the value as we are stepping and be done with it. The code for doing what I described is already being done for the "expire" attribute and it looks as follows. Do you really want this? for(ptr=date; *ptr != '\0'; ptr++) { if(*ptr == ';') { origLast = ';'; *ptr = '\0'; break; } } expires = cookie_ParseDate(date); *ptr=origLast;
Comment on attachment 53775 [details] [diff] [review] process max-age field yikes. I wasn't implying we should munge the string. in fact the munging you describe freaks me out a bit, I'm wondering if we should fix it up. I didn't realize atoi required the string to be terminated before the first non-digit character. sr=alecf
Attachment #53775 - Flags: superreview+
I wondered about this too but didn't think much of it since Steve's implementation appears correct and efficient. However, for reference, on windows and linux atoi() does not require the input string to be null terminated. From the atoi() man page: The atoi() function converts the initial portion of the string pointed to by nptr to int. The behaviour is the same as strtol(nptr, (char **)NULL, 10); except that atoi() does not detect errors.
I wasn't aware that atoi didn't need null termination. OK, I'll revise the patch.
Attached patch patch using atoi (obsolete) — Splinter Review
Comment on attachment 54088 [details] [diff] [review] patch using atoi >+ ptr += PL_strlen(MAXAGE); >+ gmtCookieExpires = get_current_time() + atoi(*ptr); I don't think we want to deref |ptr| when it is passed into atoi().
Attachment #54088 - Flags: needs-work+
Attachment #54088 - Attachment is obsolete: true
Attachment #53775 - Attachment is obsolete: true
Samir, you were too quick. I had posted the patch before compiling it (because my tree was building) and was waiting for the build to finish before asking you to re-review it. alecf, sgehani, you can re-review it now -- it has successfully compiled.
Comment on attachment 54122 [details] [diff] [review] fix compilation error in previous patch ok, finally we have something nice :) sr=alecf
Attachment #54122 - Flags: superreview+
Comment on attachment 54122 [details] [diff] [review] fix compilation error in previous patch r=sgehani again :o)
Attachment #54122 - Flags: review+
fix checked in
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: