Skip to content

Commit a14424a

Browse files
committed
Fix off-by-one error in the maxlen parameter handling.
1 parent 6cf8ce1 commit a14424a

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/bin/pg_dump/sprompt.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright 2000 by PostgreSQL Global Development Group
55
*
6-
* $Header: /cvsroot/pgsql/src/bin/pg_dump/Attic/sprompt.c,v 1.3 2002/09/11 17:32:37 momjian Exp $
6+
* $Header: /cvsroot/pgsql/src/bin/pg_dump/Attic/sprompt.c,v 1.4 2003/03/18 22:09:37 petere Exp $
77
*/
88

99
/*
@@ -45,7 +45,7 @@ simple_prompt(const char *prompt, int maxlen, bool echo)
4545
t;
4646
#endif
4747

48-
destination = (char *) malloc(maxlen + 2);
48+
destination = (char *) malloc(maxlen + 1);
4949
if (!destination)
5050
return NULL;
5151

@@ -83,7 +83,7 @@ simple_prompt(const char *prompt, int maxlen, bool echo)
8383
fflush(termout);
8484
}
8585

86-
if (fgets(destination, maxlen, termin) == NULL)
86+
if (fgets(destination, maxlen + 1, termin) == NULL)
8787
destination[0] = '\0';
8888

8989
length = strlen(destination);

src/bin/psql/sprompt.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright 2000 by PostgreSQL Global Development Group
55
*
6-
* $Header: /cvsroot/pgsql/src/bin/psql/Attic/sprompt.c,v 1.3 2002/09/04 20:31:36 momjian Exp $
6+
* $Header: /cvsroot/pgsql/src/bin/psql/Attic/sprompt.c,v 1.4 2003/03/18 22:09:37 petere Exp $
77
*/
88

99

@@ -44,7 +44,7 @@ simple_prompt(const char *prompt, int maxlen, bool echo)
4444
t;
4545
#endif
4646

47-
destination = (char *) malloc(maxlen + 2);
47+
destination = (char *) malloc(maxlen + 1);
4848
if (!destination)
4949
return NULL;
5050

@@ -82,7 +82,7 @@ simple_prompt(const char *prompt, int maxlen, bool echo)
8282
fflush(termout);
8383
}
8484

85-
if (fgets(destination, maxlen, termin) == NULL)
85+
if (fgets(destination, maxlen + 1, termin) == NULL)
8686
destination[0] = '\0';
8787

8888
length = strlen(destination);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy