From 66658fd803ede14be505b0105b1e237f235821ed Mon Sep 17 00:00:00 2001 From: hvlad Date: Sun, 24 Jul 2005 15:53:06 +0000 Subject: [PATCH] Fixed unregistered bug - crash occured in service gfix code when it tried to reattach to currently unavailable database. Since service can't interact with end user an endless loop leads to overflow service buffer and crash as result. --- src/alice/tdr.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/alice/tdr.cpp b/src/alice/tdr.cpp index bf72a4b643..b2faf397c5 100644 --- a/src/alice/tdr.cpp +++ b/src/alice/tdr.cpp @@ -694,6 +694,9 @@ static void print_description(const tdr* trans) static ULONG ask(void) { +#ifndef SUPERCLIENT + return (ULONG)-1; +#else char response[32]; AliceGlobals* tdgbl = AliceGlobals::getSpecific(); @@ -707,9 +710,9 @@ static ULONG ask(void) fflush(stdout); int c; char* p; - for (p = response; (c = getchar()) != '\n' && c != EOF;) + for (p = response; (c = getchar()) != '\n' && !feof(stdin) && !ferror(stdin);) *p++ = c; - if (c == EOF && p == response) + if (p == response) return (ULONG) -1; *p = 0; ALICE_down_case(response, response, sizeof(response)); @@ -726,6 +729,7 @@ static ULONG ask(void) switches |= sw_rollback; return switches; +#endif } @@ -804,10 +808,11 @@ static void reattach_database(TDR trans) ALICE_print(87, reinterpret_cast(trans->tdr_fullpath->str_data), 0, 0, 0, 0); // msg 87: Original path: %s +#ifdef SUPERCLIENT for (;;) { ALICE_print(88, 0, 0, 0, 0, 0); // msg 88: Enter a valid path: char* p = buffer; - while (p < end && (*p = getchar()) != '\n') + while (p < end && (*p = getchar()) != '\n' && !feof(stdin) && !ferror(stdin)) ++p; *p = 0; if (!buffer[0]) @@ -828,6 +833,7 @@ static void reattach_database(TDR trans) } ALICE_print(89, 0, 0, 0, 0, 0); // msg 89: Attach unsuccessful. } +#endif }