This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch

[PATCH gmnisrv] serve: fix gcc-9.3.0 error in serve_autoindex

Message ID
DKIM signature
Download raw message
Patch: +1 -1
gcc 9.3.0 catches an off-by-one error with strncat in serve_autoindex
where it might not write a 0 byte:

  In function ‘strncat’,
      inlined from ‘serve_autoindex’ at src/serve.c:60:3:
  error: ‘__builtin___strncat_chk’ specified bound 4097 equals destination size

Signed-off-by: William Casarin <jb55@jb55.com>
 src/serve.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/serve.c b/src/serve.c
index e42944e..bcb4b8c 100644
--- a/src/serve.c
+++ b/src/serve.c
@@ -57,7 +57,7 @@ serve_autoindex(struct gmnisrv_client *client, const char *path)
	while ((ent = readdir(dirp)) != NULL) {
		char fpath[PATH_MAX + 1];
		strcpy(fpath, path);
		strncat(fpath, ent->d_name, sizeof(fpath));
		strncat(fpath, ent->d_name, sizeof(fpath)-1);

		struct stat st;
		if (stat(fpath, &st) != 0) {
Review patch Export thread (mbox)