have to blindly assume that the buffer is big enough.
-const char cgi_rcs[] = "$Id: cgi.c,v 1.103 2008/03/21 11:13:57 fabiankeil Exp $";
+const char cgi_rcs[] = "$Id: cgi.c,v 1.104 2008/03/26 18:07:06 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/cgi.c,v $
*
* Revisions :
* $Log: cgi.c,v $
+ * Revision 1.104 2008/03/26 18:07:06 fabiankeil
+ * Add hostname directive. Closes PR#1918189.
+ *
* Revision 1.103 2008/03/21 11:13:57 fabiankeil
* Only gather host information if it's actually needed.
* Also move the code out of accept_connection() so it's less likely
* HTTP header - e.g.:
* "Sun, 06 Nov 1994 08:49:37 GMT"
*
- * XXX: Should probably get a third parameter for
- * the buffer size.
- *
* Parameters :
* 1 : time_offset = Time returned will be current time
* plus this number of seconds.
- * 2 : buf = Destination for result. Must be long enough
- * to hold 29 characters plus a trailing zero.
+ * 2 : buf = Destination for result.
+ * 3 : buffer_size = Size of the buffer above. Must be big
+ * enough to hold 29 characters plus a
+ * trailing zero.
*
* Returns : N/A
*
*********************************************************************/
-void get_http_time(int time_offset, char *buf)
+void get_http_time(int time_offset, char *buf, size_t buffer_size)
{
static const char day_names[7][4] =
{ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
#endif
assert(buf);
+ assert(buffer_size > 29);
time(¤t_time); /* get current time */
}
/* Format: "Sun, 06 Nov 1994 08:49:37 GMT" */
- snprintf(buf, 30,
+ snprintf(buf, buffer_size,
"%s, %02d %s %4d %02d:%02d:%02d GMT",
day_names[t->tm_wday],
t->tm_mday,
if (!err)
{
- get_http_time(0, buf);
+ get_http_time(0, buf, sizeof(buf));
err = enlist_unique_header(rsp->headers, "Date", buf);
}
if (!err)
{
- get_http_time(10 * 60, buf); /* 10 * 60sec = 10 minutes */
+ get_http_time(10 * 60, buf, sizeof(buf)); /* 10 * 60sec = 10 minutes */
err = enlist_unique_header(rsp->headers, "Expires", buf);
}
}
else if (!strncmpic(rsp->status, "302", 3))
{
- get_http_time(0, buf);
+ get_http_time(0, buf, sizeof(buf));
if (!err) err = enlist_unique_header(rsp->headers, "Date", buf);
}
else
*/
if (!err) err = enlist_unique_header(rsp->headers, "Cache-Control", "no-cache");
- get_http_time(0, buf);
+ get_http_time(0, buf, sizeof(buf));
if (!err) err = enlist_unique_header(rsp->headers, "Date", buf);
if (!strncmpic(rsp->status, "403", 3)
|| !strncmpic(rsp->status, "404", 3)
#ifndef CGI_H_INCLUDED
#define CGI_H_INCLUDED
-#define CGI_H_VERSION "$Id: cgi.h,v 1.32 2006/12/17 17:53:39 fabiankeil Exp $"
+#define CGI_H_VERSION "$Id: cgi.h,v 1.33 2007/01/28 13:41:17 fabiankeil Exp $"
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/cgi.h,v $
*
* Revisions :
* $Log: cgi.h,v $
+ * Revision 1.33 2007/01/28 13:41:17 fabiankeil
+ * - Add HEAD support to finish_http_response.
+ * - Add error favicon to internal HTML error messages.
+ *
* Revision 1.32 2006/12/17 17:53:39 fabiankeil
* Suppress the toggle link if remote toggling is disabled.
*
/*
* Text generators
*/
-extern void get_http_time(int time_offset, char * buf);
+extern void get_http_time(int time_offset, char *buf, size_t buffer_size);
extern char *add_help_link(const char *item, struct configuration_spec *config);
extern char *make_menu(const char *self, const unsigned feature_flags);
extern char *dump_map(const struct map *the_map);
-const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.67 2008/03/27 17:00:05 fabiankeil Exp $";
+const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.68 2008/03/27 18:27:21 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/cgisimple.c,v $
*
* Revisions :
* $Log: cgisimple.c,v $
+ * Revision 1.68 2008/03/27 18:27:21 fabiankeil
+ * Remove kill-popups action.
+ *
* Revision 1.67 2008/03/27 17:00:05 fabiankeil
* Turn the favicon blobs into locals.
*
rsp->is_static = 1;
- get_http_time(7 * 24 * 60 * 60, buf); /* 7 days into future */
+ get_http_time(7 * 24 * 60 * 60, buf, sizeof(buf)); /* 7 days into future */
if (!err) err = enlist_unique_header(rsp->headers, "Expires", buf);
return (err ? JB_ERR_MEMORY : JB_ERR_OK);
-const char parsers_rcs[] = "$Id: parsers.c,v 1.123 2008/03/29 12:13:46 fabiankeil Exp $";
+const char parsers_rcs[] = "$Id: parsers.c,v 1.124 2008/04/16 16:38:21 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/parsers.c,v $
*
* Revisions :
* $Log: parsers.c,v $
+ * Revision 1.124 2008/04/16 16:38:21 fabiankeil
+ * Don't pass the whole csp structure to flush_socket()
+ * when it only needs a file descriptor and a buffer.
+ *
* Revision 1.123 2008/03/29 12:13:46 fabiankeil
* Remove send-wafer and send-vanilla-wafer actions.
*
/*
* Setting Last-Modified Header to now.
*/
- get_http_time(0, buf);
+ get_http_time(0, buf, sizeof(buf));
freez(*header);
*header = strdup("Last-Modified: ");
string_append(header, buf);
#ifndef PARSERS_H_INCLUDED
#define PARSERS_H_INCLUDED
-#define PARSERS_H_VERSION "$Id: parsers.h,v 1.40 2007/08/11 14:47:26 fabiankeil Exp $"
+#define PARSERS_H_VERSION "$Id: parsers.h,v 1.41 2008/04/16 16:38:21 fabiankeil Exp $"
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/parsers.h,v $
*
* Revisions :
* $Log: parsers.h,v $
+ * Revision 1.41 2008/04/16 16:38:21 fabiankeil
+ * Don't pass the whole csp structure to flush_socket()
+ * when it only needs a file descriptor and a buffer.
+ *
* Revision 1.40 2007/08/11 14:47:26 fabiankeil
* Remove the prototypes for functions that are only
* used in parsers.c and thus should be static.
extern char *get_header(struct client_state *csp);
extern char *get_header_value(const struct list *header_list, const char *header_name);
extern jb_err sed(const struct parsers pats[], const add_header_func_ptr more_headers[], struct client_state *csp);
-extern void get_http_time(int time_offset, char *buf);
+extern void get_http_time(int time_offset, char *buf, size_t buffer_size);
extern jb_err get_destination_from_headers(const struct list *headers, struct http_request *http);
#ifdef FEATURE_FORCE_LOAD