diff options
author | Peter Eisentraut <peter_e@gmx.net> | 2003-03-18 22:09:37 +0000 |
---|---|---|
committer | Peter Eisentraut <peter_e@gmx.net> | 2003-03-18 22:09:37 +0000 |
commit | a14424a9d2fdad6e909818c6874cbd4eba9a0030 (patch) | |
tree | 5154c22d0b715c25fbbf228fc2d47974665b9d7a | |
parent | 6cf8ce13dbbc8f0a6e2ee46907a46dd0613ae319 (diff) | |
download | postgresql-a14424a9d2fdad6e909818c6874cbd4eba9a0030.tar.gz postgresql-a14424a9d2fdad6e909818c6874cbd4eba9a0030.zip |
Fix off-by-one error in the maxlen parameter handling.
-rw-r--r-- | src/bin/pg_dump/sprompt.c | 6 | ||||
-rw-r--r-- | src/bin/psql/sprompt.c | 6 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/bin/pg_dump/sprompt.c b/src/bin/pg_dump/sprompt.c index 767d984ac26..9c0d4f0db6a 100644 --- a/src/bin/pg_dump/sprompt.c +++ b/src/bin/pg_dump/sprompt.c @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/pg_dump/Attic/sprompt.c,v 1.3 2002/09/11 17:32:37 momjian Exp $ + * $Header: /cvsroot/pgsql/src/bin/pg_dump/Attic/sprompt.c,v 1.4 2003/03/18 22:09:37 petere Exp $ */ /* @@ -45,7 +45,7 @@ simple_prompt(const char *prompt, int maxlen, bool echo) t; #endif - destination = (char *) malloc(maxlen + 2); + destination = (char *) malloc(maxlen + 1); if (!destination) return NULL; @@ -83,7 +83,7 @@ simple_prompt(const char *prompt, int maxlen, bool echo) fflush(termout); } - if (fgets(destination, maxlen, termin) == NULL) + if (fgets(destination, maxlen + 1, termin) == NULL) destination[0] = '\0'; length = strlen(destination); diff --git a/src/bin/psql/sprompt.c b/src/bin/psql/sprompt.c index d05b294bfa5..46ac2d97ba6 100644 --- a/src/bin/psql/sprompt.c +++ b/src/bin/psql/sprompt.c @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/Attic/sprompt.c,v 1.3 2002/09/04 20:31:36 momjian Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/Attic/sprompt.c,v 1.4 2003/03/18 22:09:37 petere Exp $ */ @@ -44,7 +44,7 @@ simple_prompt(const char *prompt, int maxlen, bool echo) t; #endif - destination = (char *) malloc(maxlen + 2); + destination = (char *) malloc(maxlen + 1); if (!destination) return NULL; @@ -82,7 +82,7 @@ simple_prompt(const char *prompt, int maxlen, bool echo) fflush(termout); } - if (fgets(destination, maxlen, termin) == NULL) + if (fgets(destination, maxlen + 1, termin) == NULL) destination[0] = '\0'; length = strlen(destination); |