From: Jeremy Allison Date: Fri, 13 Dec 2019 17:39:55 +0000 (-0800) Subject: s3: smbd: msdfs: Cleanup, don't mix int and size_t types for a count variable. X-Git-Tag: ldb-2.1.0~255 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2048ff3adc4dbff659dfb5d747f0cb93baad06ee;p=thirdparty%2Fsamba.git 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 --- diff --git a/source3/smbd/msdfs.c b/source3/smbd/msdfs.c index a70e795f0ca..67e736a84f0 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);