cifs: fix off-by-one bug in build_unc_path_to_root
Subsystems (2)
PATCH 1/1 cifs: fix off-by-one bug in build_unc_path_to_root
commit 839db3d10a (cifs: fix up handling of prefixpath= option) changed the code such that the vol->prepath no longer contained a leading delimiter and then fixed up the places that accessed that field to account for that change.
One spot in build_unc_path_to_root was missed however. When doing the pointer addition on pos, that patch failed to account for the fact that we had already incremented "pos" by one when adding the length of the prepath. This caused a buffer overrun by one byte.
This patch fixes the problem by correcting the handling of "pos".
--- fs/cifs/connect.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/cifs/connect.c +2 -2
@@ -3279,8 +3279,8 @@ build_unc_path_to_root(const struct smb_vol *vol, pos = full_path + unc_len;if (pplen) { - *pos++ =CIFS_DIR_SEP (cifs_sb); -strncpy (pos, vol->prepath, pplen); + *pos =CIFS_DIR_SEP (cifs_sb); +strncpy (pos +1 , vol->prepath, pplen); pos += pplen; }
Signature · 1 line
1.8.1.4
A message that is not in the archive (sent off-list or not yet received): 1370008818-9427-1-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Steve French
Appliedmerged into cifs-2.6.git for-3.10 (and also in for-3.11 tree)
(also updated for 3.11 and equivalently for-next with another patch "cifs: remove the cifs_ses->flags field" and continuing to work through your large auth update patch series)
Quoted 38 lines · Jeff Layton
commit
839db3d10a(cifs: fix up handling of prefixpath= option) changed the code such that thevol->prepathno longer contained a leading delimiter and then fixed up the places that accessed that field to account for that change.One spot in
build_unc_path_to_rootwas missed however. When doing the pointer addition on pos, that patch failed to account for the fact that we had already incremented "pos" by one when adding the length of the prepath. This caused a buffer overrun by one byte.This patch fixes the problem by correcting the handling of "pos".
Cc <[email protected]> # v3.8+Reported-by Marcus Moeller <[email protected]>Reported-by Ken Fallon <[email protected]>Signed-off-by Jeff Layton <[email protected]>--- fs/cifs/connect.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)fs/cifs/connect.c +2
-3@@ -3279,8 +3279,8 @@ build_unc_path_to_root(const struct smb_vol *vol, pos = full_path + unc_len;if (pplen) { - *pos++ =CIFS_DIR_SEP (cifs_sb); -strncpy (pos, vol->prepath, pplen); + *pos =CIFS_DIR_SEP (cifs_sb); +strncpy (pos +1 , vol->prepath, pplen); pos += pplen; } --1.8.1.4
Signature · 3 lines
Thanks, Steve