diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2018-01-13 12:45:55 +0100 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2018-01-13 12:45:55 +0100 |
commit | d2765b90ce67a26db4ff980842f0a0f3dc37d546 (patch) | |
tree | d2f8f20a06a5bfe27fc2e76bdef7324bad07c6f0 /mimetypes | |
parent | 0a7b600cc7903de58177499f699c25e0ae34369f (diff) | |
download | fileserv-d2765b90ce67a26db4ff980842f0a0f3dc37d546.tar.gz fileserv-d2765b90ce67a26db4ff980842f0a0f3dc37d546.tar.bz2 |
Bugfixes
* mimetypes/err.c (print_locus_range): Fix output length.
* mimetypes/grammar.y (rule_line): Initialize locus range.
* mimetypes/prloc.c (locus_range_format): Fix memory overrun;
terminate output with null byte.
* src/fileserv.c: New option -i (index page).
Diffstat (limited to 'mimetypes')
-rw-r--r-- | mimetypes/err.c | 2 | ||||
-rw-r--r-- | mimetypes/grammar.y | 1 | ||||
-rw-r--r-- | mimetypes/prloc.c | 2 |
3 files changed, 3 insertions, 2 deletions
diff --git a/mimetypes/err.c b/mimetypes/err.c index 01164c9..be5002e 100644 --- a/mimetypes/err.c +++ b/mimetypes/err.c @@ -145,7 +145,7 @@ print_locus_range (FILE *fp, struct locus_range const *lr) n = locus_range_format (&buf, &buflen, lr); if (n < 0) return; - fwrite (buf, buflen, 1, fp); + fwrite (buf, n, 1, fp); free (buf); } diff --git a/mimetypes/grammar.y b/mimetypes/grammar.y index 442ba84..1864289 100644 --- a/mimetypes/grammar.y +++ b/mimetypes/grammar.y @@ -134,6 +134,7 @@ rule_line: /* empty */ if (!p) mimetypes_nomem (); LLE_APPEND (&rule_list, p, link); + locus_range_init (&p->loc); p->type = $1.ptr; p->node = $2; p->priority = $3; diff --git a/mimetypes/prloc.c b/mimetypes/prloc.c index d53883c..4555a56 100644 --- a/mimetypes/prloc.c +++ b/mimetypes/prloc.c @@ -150,7 +150,6 @@ locus_range_format (char **pbuf, size_t *psize, struct locus_range const *lr) *psize = size; } n = _lpprint (buf, &lr->beg, PR_ALL); - buf += n; if (lr->end.file) { int flag = PR_NON; @@ -168,5 +167,6 @@ locus_range_format (char **pbuf, size_t *psize, struct locus_range const *lr) n += _lpprint (buf + n, &lr->end, flag); } } + buf[n] = 0; return n; } |