1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-05 13:16:09 +03:00

Fixed a bug in mysql client.

client/mysql.cc:
  Fixed a bug that caused segmentation fault in internal 'tee' command.
This commit is contained in:
unknown
2002-05-31 12:34:47 +03:00
parent 95f2b1e6a8
commit 79efd9dbaa

View File

@@ -40,7 +40,7 @@
#include <signal.h> #include <signal.h>
#include <violite.h> #include <violite.h>
const char *VER= "12.8"; const char *VER= "12.9";
/* Don't try to make a nice table if the data is too big */ /* Don't try to make a nice table if the data is too big */
#define MAX_COLUMN_LENGTH 1024 #define MAX_COLUMN_LENGTH 1024
@@ -617,13 +617,11 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
{ {
if (opt_outfile) if (opt_outfile)
end_tee(); end_tee();
opt_outfile= 0;
} }
else else
if (!opt_outfile) if (!opt_outfile)
{ {
strmov(outfile, argument); strmov(outfile, argument);
opt_outfile= 1;
init_tee(); init_tee();
} }
break; break;
@@ -631,7 +629,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
printf("WARNING: option depricated; use --disable-tee instead.\n"); printf("WARNING: option depricated; use --disable-tee instead.\n");
if (opt_outfile) if (opt_outfile)
end_tee(); end_tee();
opt_outfile= 0;
break; break;
case OPT_PAGER: case OPT_PAGER:
opt_nopager= 0; opt_nopager= 0;
@@ -1510,17 +1507,22 @@ static void end_pager()
static void init_tee() static void init_tee()
{ {
if (opt_outfile)
end_tee();
if (!(OUTFILE= my_fopen(outfile, O_APPEND | O_WRONLY, MYF(MY_WME)))) if (!(OUTFILE= my_fopen(outfile, O_APPEND | O_WRONLY, MYF(MY_WME))))
{ {
opt_outfile= 0; opt_outfile= 0;
init_pager(); init_pager();
return; return;
} }
opt_outfile= 1;
tee_fprintf(stdout, "Logging to file '%s'\n", outfile);
} }
static void end_tee() static void end_tee()
{ {
my_fclose(OUTFILE, MYF(0)); my_fclose(OUTFILE, MYF(0));
opt_outfile= 0;
return; return;
} }
@@ -1826,7 +1828,7 @@ com_tee(String *buffer, char *line __attribute__((unused)))
{ {
if (!strlen(outfile)) if (!strlen(outfile))
{ {
printf("No previous outfile available, you must give the filename!\n"); printf("No previous outfile available, you must give a filename!\n");
opt_outfile= 0; opt_outfile= 0;
return 0; return 0;
} }
@@ -1846,12 +1848,7 @@ com_tee(String *buffer, char *line __attribute__((unused)))
printf("No outfile specified!\n"); printf("No outfile specified!\n");
return 0; return 0;
} }
if (!opt_outfile)
{
init_tee(); init_tee();
opt_outfile=1;
}
tee_fprintf(stdout, "Logging to file '%s'\n", outfile);
return 0; return 0;
} }
@@ -1861,7 +1858,6 @@ com_notee(String *buffer __attribute__((unused)),
{ {
if (opt_outfile) if (opt_outfile)
end_tee(); end_tee();
opt_outfile=0;
tee_fprintf(stdout, "Outfile disabled.\n"); tee_fprintf(stdout, "Outfile disabled.\n");
return 0; return 0;
} }
@@ -2284,11 +2280,11 @@ com_status(String *buffer __attribute__((unused)),
} }
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
if (mysql.net.vio->ssl_ && SSL_get_cipher(mysql.net.vio->ssl_)) if (mysql.net.vio->ssl_ && SSL_get_cipher(mysql.net.vio->ssl_))
tee_fprintf(stdout, "SSL cipher in use is %s\n", tee_fprintf(stdout, "SSL:\t\t\tCipher in use is %s\n",
SSL_get_cipher(mysql.net.vio->ssl_)); SSL_get_cipher(mysql.net.vio->ssl_));
else else
#endif /* HAVE_OPENSSL */ #endif /* HAVE_OPENSSL */
tee_puts("SSL is not in use\n", stdout); tee_puts("SSL:\t\t\tNot in use", stdout);
} }
else else
{ {