File: mod_ssi-set-tmp-file-length-if-ssi-exec-fails.patch

package info (click to toggle)
lighttpd 1.4.79-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 7,492 kB
  • sloc: ansic: 99,486; perl: 2,607; sh: 783; yacc: 726; makefile: 705
file content (38 lines) | stat: -rw-r--r-- 1,388 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
From 45918e7a2a90a17afd0e9e360be39cfa037f5e9a Mon Sep 17 00:00:00 2001
From: Glenn Strauss <gstrauss@gluelogic.com>
Date: Sun, 11 May 2025 16:59:43 -0400
Subject: [PATCH] [mod_ssi] set tmp file length if ssi exec fails
Origin: upstream, https://git.lighttpd.net/lighttpd/lighttpd1.4/commit/45918e7a2a90a17afd0e9e360be39cfa037f5e9a
Forwarded: not-needed

- set tmp file length properly if ssi exec fails
- use safer memmove() when moving data in buffer after SSI HTML comment
---
 src/mod_ssi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mod_ssi.c b/src/mod_ssi.c
index d17d39e9..496eaa61 100644
--- a/src/mod_ssi.c
+++ b/src/mod_ssi.c
@@ -1166,7 +1166,7 @@ static int process_ssi_stmt(request_st * const r, handler_ctx * const p, const c
 
 		int status = 0;
 		struct stat stb;
-		stb.st_size = 0;
+		stb.st_size = flen;
 		/*(expects STDIN_FILENO open to /dev/null)*/
 		int serrh_fd = r->conf.serrh ? r->conf.serrh->fd : -1;
 		pid = fdevent_sh_exec(cmd, NULL, -1, c->file.fd, serrh_fd);
@@ -1514,7 +1514,7 @@ static void mod_ssi_read_fd(request_st * const r, handler_ctx * const p, struct
 				if (prelen - pretag && !p->if_is_false) {
 					chunkqueue_append_mem(cq, buf+pretag, prelen-pretag);
 				}
-				memcpy(buf, buf+prelen, (offset -= prelen));
+				memmove(buf, buf+prelen, (offset -= prelen));
 				pretag = 0;
 				break;
 			}
-- 
2.49.0