[02/11] gssd: Fix cccache buffer size
diff mbox series

Message ID 20200718092421.31691-3-nazard@nazar.ca
State New
Headers show
Series
  • nfs-utils: Misc cleanups & fixes
Related show

Commit Message

Doug Nazar July 18, 2020, 9:24 a.m. UTC
Signed-off-by: Doug Nazar <nazard@nazar.ca>
---
 utils/gssd/krb5_util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Steve Dickson July 20, 2020, 2:43 p.m. UTC | #1
Hey Doug,

On 7/18/20 5:24 AM, Doug Nazar wrote:
> Signed-off-by: Doug Nazar <nazard@nazar.ca>
> ---
>  utils/gssd/krb5_util.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/utils/gssd/krb5_util.c b/utils/gssd/krb5_util.c
> index e5b81823..34c81daa 100644
> --- a/utils/gssd/krb5_util.c
> +++ b/utils/gssd/krb5_util.c
> @@ -1225,7 +1225,7 @@ out:
>  int
>  gssd_setup_krb5_user_gss_ccache(uid_t uid, char *servername, char *dirpattern)
>  {
> -	char			buf[PATH_MAX+2+256], dirname[PATH_MAX];
> +	char			buf[PATH_MAX+4+2+256], dirname[PATH_MAX];
>  	const char		*cctype;
>  	struct dirent		*d;
>  	int			err, i, j;
> 
Thanks for point this out but I think I'm going to go with this:

diff --git a/utils/gssd/krb5_util.c b/utils/gssd/krb5_util.c
index e5b8182..cd5a919 100644
--- a/utils/gssd/krb5_util.c
+++ b/utils/gssd/krb5_util.c
@@ -223,7 +223,8 @@ gssd_find_existing_krb5_ccache(uid_t uid, char *dirname,
 	int found = 0;
 	struct dirent *best_match_dir = NULL;
 	struct stat best_match_stat, tmp_stat;
-	char buf[PATH_MAX+4+2+256];
+	/* dirname + cctype + d_name + NULL */
+	char buf[PATH_MAX+5+256+1];
 	char *princname = NULL;
 	char *realm = NULL;
 	int score, best_match_score = 0, err = -EACCES;
@@ -1225,7 +1226,8 @@ out:
 int
 gssd_setup_krb5_user_gss_ccache(uid_t uid, char *servername, char *dirpattern)
 {
-	char			buf[PATH_MAX+2+256], dirname[PATH_MAX];
+				/* dirname + cctype + d_name + NULL */
+	char			buf[PATH_MAX+5+256+1], dirname[PATH_MAX];
 	const char		*cctype;
 	struct dirent		*d;
 	int			err, i, j;

which explains the needed space and as well removes the warning... 

steved
Doug Nazar July 20, 2020, 3:41 p.m. UTC | #2
On 2020-07-20 10:43, Steve Dickson wrote:
> Thanks for point this out but I think I'm going to go with this:
> -	char buf[PATH_MAX+4+2+256];
> +	/* dirname + cctype + d_name + NULL */
> +	char buf[PATH_MAX+5+256+1];
>
> which explains the needed space and as well removes the warning...

That's fine. I didn't spend much time wondering why it was written that 
way, just assumed there was a reason.

Doug

Patch
diff mbox series

diff --git a/utils/gssd/krb5_util.c b/utils/gssd/krb5_util.c
index e5b81823..34c81daa 100644
--- a/utils/gssd/krb5_util.c
+++ b/utils/gssd/krb5_util.c
@@ -1225,7 +1225,7 @@  out:
 int
 gssd_setup_krb5_user_gss_ccache(uid_t uid, char *servername, char *dirpattern)
 {
-	char			buf[PATH_MAX+2+256], dirname[PATH_MAX];
+	char			buf[PATH_MAX+4+2+256], dirname[PATH_MAX];
 	const char		*cctype;
 	struct dirent		*d;
 	int			err, i, j;