~sircmpwn/gmni-devel

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

Details
Message ID
<20201015154807.7031-1-jb55@jb55.com>
DKIM signature
missing
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:
  /nix/store/...glibc-2.31-dev/include/bits/string_fortified.h:136:10:
  error: ‘__builtin___strncat_chk’ specified bound 4097 equals destination size
  [-Werror=stringop-overflow=]

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) {
-- 
2.28.0
Review patch Export thread (mbox)