myadm

Simple MySQL client for the terminal
git clone git://git.bitsmanent.org/myadm
Log | Files | Refs | README | LICENSE

commit 7e8b2037c7485bada6da24d915c05288282ca220
parent b515edadf4d06c75e7e051a1574d154b5d04aee4
Author: Claudio Alessi <smoppy@gmail.com>
Date:   Mon, 16 May 2016 22:11:31 +0200

Fix an overflow.
Also remove a build warning.

Diffstat:
Mmyadm.c | 7+++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/myadm.c b/myadm.c @@ -519,7 +519,9 @@ mysql_file_exec(char *file) { size = read(fd, buf, MAXQUERYLEN); if(size == -1) return -2; - buf[size+1] = '\0'; + if(!size) + return 0; + buf[size] = '\0'; /* We do not want flow control chars to be interpreted. */ size += escape(esc, buf, size, '\\', '\''); r = mysql_exec(esc); @@ -657,9 +659,10 @@ ui_sql_edit_exec(char *sql) { break; } if(mysql_file_exec(tmpf) < 0) { - if(*mysql_error(mysql)) + if(*mysql_error(mysql)) { if(ui_ask("An error occurred. Continue editing ([y]/n)?", "yn") == 'y') continue; + } else ui_set("status", "Something went wrong."); break;