+2012-11-26 Giuseppe Scrivano <gscrivano@gnu.org>
+
+ * wget.h (MAX_INT_TO_STRING_LEN): Define macro.
+ * warc.c (warc_write_block_from_file): Use `MAX_INT_TO_STRING_LEN'
+ to find the buffer size.
+ (warc_write_cdx_record): Likewise.
+
2012-09-03 Tim Ruehsen <tim.ruehsen@gmx.de>
* http.c (digest_authentication_encode): Add support for RFC 2617
warc_write_block_from_file (FILE *data_in)
{
/* Add the Content-Length header. */
- char content_length[22];
+ char content_length[MAX_INT_TO_STRING_LEN(off_t)];
fseeko (data_in, 0L, SEEK_END);
number_to_string (content_length, ftello (data_in));
warc_write_header ("Content-Length", content_length);
if (redirect_location == NULL || strlen(redirect_location) == 0)
redirect_location = "-";
- char offset_string[22];
+ char offset_string[MAX_INT_TO_STRING_LEN(off_t)];
number_to_string (offset_string, offset);
/* Print the CDX line. */
0-pad the address.) */
#define PTR_FORMAT(p) (int) (2 * sizeof (void *)), (unsigned long) (p)
+/* Find the maximum buffer length needed to print an integer of type `x'
+ in base 10. 24082 / 10000 = 8*log_{10}(2). */
+#define MAX_INT_TO_STRING_LEN(x) ((sizeof(x) * 24082 / 10000) + 2)
+
extern const char *exec_name;
\f
/* Document type ("dt") flags */