From 2048ff3adc4dbff659dfb5d747f0cb93baad06ee Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 13 Dec 2019 09:39:55 -0800 Subject: [PATCH] s3: smbd: msdfs: Cleanup, don't mix int and size_t types for a count variable. Add integer wrap check. Signed-off-by: Jeremy Allison Reviewed-by: Ralph Boehme --- source3/smbd/msdfs.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source3/smbd/msdfs.c b/source3/smbd/msdfs.c index a70e795f0caf..67e736a84f08 100644 --- a/source3/smbd/msdfs.c +++ b/source3/smbd/msdfs.c @@ -1500,7 +1500,7 @@ bool remove_msdfs_link(const struct junction_map *jucn) Return the number of DFS links at the root of this share. *********************************************************************/ -static int count_dfs_links(TALLOC_CTX *ctx, int snum) +static size_t count_dfs_links(TALLOC_CTX *ctx, int snum) { TALLOC_CTX *frame = talloc_stackframe(); const struct loadparm_substitution *lp_sub = @@ -1573,6 +1573,10 @@ static int count_dfs_links(TALLOC_CTX *ctx, int snum) goto out; } if (is_msdfs_link(conn, smb_dname)) { + if (cnt + 1 < cnt) { + cnt = 0; + goto out; + } cnt++; } TALLOC_FREE(talloced); -- 2.34.1