Fix update_pool_passwd()'s lack of dirname() usage portability.
authorTatsuo Ishii <ishii at sraoss.co.jp>
Thu, 13 Jan 2011 06:10:05 +0000 (06:10 +0000)
committerTatsuo Ishii <ishii at sraoss.co.jp>
Thu, 13 Jan 2011 06:10:05 +0000 (06:10 +0000)
pg_md5.c

index 32b8e9850e233ab553f42a67615729ebba1a732c..b2b90778e282070c13df5857a3fc298641f92385 100644 (file)
--- a/pg_md5.c
+++ b/pg_md5.c
@@ -5,7 +5,7 @@
  * pgpool: a language independent connection pool server for PostgreSQL
  * written by Tatsuo Ishii
  *
- * Copyright (c) 2003-2010     PgPool Global Development Group
+ * Copyright (c) 2003-2011     PgPool Global Development Group
  *
  * Permission to use, copy, modify, and distribute this software and
  * its documentation for any purpose and without fee is hereby
@@ -172,6 +172,8 @@ static void update_pool_passwd(char *conf_file, char *password)
        struct passwd *pw;
        char     md5[MD5_PASSWD_LEN+1];
        char pool_passwd[POOLMAXPATHLEN+1];
+       char dirnamebuf[POOLMAXPATHLEN+1];
+       char *dirp;
 
        if (pool_init_config())
        {
@@ -184,8 +186,10 @@ static void update_pool_passwd(char *conf_file, char *password)
                exit(EXIT_FAILURE);
        }
 
+       strncpy(dirnamebuf, conf_file, sizeof(dirnamebuf));
+       dirp = dirname(dirnamebuf);
        snprintf(pool_passwd, sizeof(pool_passwd), "%s/%s",
-                        dirname(conf_file), pool_config->pool_passwd);
+                        dirp, pool_config->pool_passwd);
        pool_init_pool_passwd(pool_passwd);
 
        pw = getpwuid(getuid());