Properly format Content-Length: header on 32-bit systems.

- Promote len argument in dump_content_length to uint64_t.
- Make sure there is sufficient scratch space to format string.
- Use PRIu64 macro for formatting.

Signed-off-by: Jan Harkes <jaharkes@cs.cmu.edu>
This commit is contained in:
Jan Harkes 2013-03-07 16:07:26 -05:00
parent 439d0e334d
commit 416b962c85
2 changed files with 4 additions and 4 deletions

View File

@ -227,10 +227,10 @@ void dump_errno(struct req_state *s, int err)
dump_status(s, buf);
}
void dump_content_length(struct req_state *s, size_t len)
void dump_content_length(struct req_state *s, uint64_t len)
{
char buf[16];
snprintf(buf, sizeof(buf), "%lu", (long unsigned int)len);
char buf[21];
snprintf(buf, sizeof(buf), "%"PRIu64, len);
int r = s->cio->print("Content-Length: %s\n", buf);
if (r < 0) {
ldout(s->cct, 0) << "ERROR: s->cio->print() returned err=" << r << dendl;

View File

@ -281,7 +281,7 @@ extern void end_header(struct req_state *s, const char *content_type = NULL);
extern void dump_start(struct req_state *s);
extern void list_all_buckets_start(struct req_state *s);
extern void dump_owner(struct req_state *s, string& id, string& name, const char *section = NULL);
extern void dump_content_length(struct req_state *s, size_t len);
extern void dump_content_length(struct req_state *s, uint64_t len);
extern void dump_etag(struct req_state *s, const char *etag);
extern void dump_last_modified(struct req_state *s, time_t t);
extern void abort_early(struct req_state *s, int err);