summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2013-01-19 13:41:39 +0100
committerFelix Fietkau <nbd@openwrt.org>2013-01-19 13:41:42 +0100
commitc6c7c4b1ec923f484e25b615d920a40d917d2936 (patch)
tree6d8ec279cef73b86e9026e92b5259347b5ec501c /file.c
parent69cfe89ca44466f295ce88faf92aabf187c9cf95 (diff)
fix file etag buffer length
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Diffstat (limited to 'file.c')
-rw-r--r--file.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/file.c b/file.c
index adc8e6d..c769c0a 100644
--- a/file.c
+++ b/file.c
@@ -274,9 +274,9 @@ static const char * uh_file_mime_lookup(const char *path)
return "application/octet-stream";
}
-static const char * uh_file_mktag(struct stat *s, char *buf)
+static const char * uh_file_mktag(struct stat *s, char *buf, int len)
{
- snprintf(buf, sizeof(buf), "\"%x-%x-%x\"",
+ snprintf(buf, len, "\"%x-%x-%x\"",
(unsigned int) s->st_ino,
(unsigned int) s->st_size,
(unsigned int) s->st_mtime);
@@ -318,7 +318,7 @@ static void uh_file_response_ok_hdrs(struct client *cl, struct stat *s)
char buf[128];
if (s) {
- ustream_printf(cl->us, "ETag: %s\r\n", uh_file_mktag(s, buf));
+ ustream_printf(cl->us, "ETag: %s\r\n", uh_file_mktag(s, buf, sizeof(buf)));
ustream_printf(cl->us, "Last-Modified: %s\r\n",
uh_file_unix2date(s->st_mtime, buf, sizeof(buf)));
}
@@ -347,7 +347,7 @@ static void uh_file_response_412(struct client *cl)
static bool uh_file_if_match(struct client *cl, struct stat *s)
{
char buf[128];
- const char *tag = uh_file_mktag(s, buf);
+ const char *tag = uh_file_mktag(s, buf, sizeof(buf));
char *hdr = uh_file_header(cl, HDR_IF_MATCH);
char *p;
int i;
@@ -388,7 +388,7 @@ static int uh_file_if_modified_since(struct client *cl, struct stat *s)
static int uh_file_if_none_match(struct client *cl, struct stat *s)
{
char buf[128];
- const char *tag = uh_file_mktag(s, buf);
+ const char *tag = uh_file_mktag(s, buf, sizeof(buf));
char *hdr = uh_file_header(cl, HDR_IF_NONE_MATCH);
char *p;
int i;