mirror of
https://github.com/postgres/postgres.git
synced 2025-05-29 16:21:20 +03:00
Fix off-by-one error in the maxlen parameter handling.
This commit is contained in:
parent
6cf8ce13db
commit
a14424a9d2
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright 2000 by PostgreSQL Global Development Group
|
* 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;
|
t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
destination = (char *) malloc(maxlen + 2);
|
destination = (char *) malloc(maxlen + 1);
|
||||||
if (!destination)
|
if (!destination)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ simple_prompt(const char *prompt, int maxlen, bool echo)
|
|||||||
fflush(termout);
|
fflush(termout);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fgets(destination, maxlen, termin) == NULL)
|
if (fgets(destination, maxlen + 1, termin) == NULL)
|
||||||
destination[0] = '\0';
|
destination[0] = '\0';
|
||||||
|
|
||||||
length = strlen(destination);
|
length = strlen(destination);
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright 2000 by PostgreSQL Global Development Group
|
* 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;
|
t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
destination = (char *) malloc(maxlen + 2);
|
destination = (char *) malloc(maxlen + 1);
|
||||||
if (!destination)
|
if (!destination)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ simple_prompt(const char *prompt, int maxlen, bool echo)
|
|||||||
fflush(termout);
|
fflush(termout);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fgets(destination, maxlen, termin) == NULL)
|
if (fgets(destination, maxlen + 1, termin) == NULL)
|
||||||
destination[0] = '\0';
|
destination[0] = '\0';
|
||||||
|
|
||||||
length = strlen(destination);
|
length = strlen(destination);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user