Permalink
Browse files

Fix mismanaged idx allocation on some startup cases

Found by: paigeadelethompson
Patch by: michaelortmann
  • Loading branch information...
michaelortmann authored and vanosg committed Oct 14, 2018
1 parent b13d29e commit eaa07e13757f0523a264795dfccffc969b7caf81
Showing with 13 additions and 13 deletions.
  1. +3 −3 src/chanprog.c
  2. +9 −9 src/main.c
  3. +1 −1 src/misc.c
@@ -272,7 +272,7 @@ void tell_verbose_uptime(int idx)
if (backgrd)
strcpy(s1, MISC_BACKGROUND);
else {
if (term_z)
if (term_z >= 0)
strcpy(s1, MISC_TERMMODE);
else if (con_chan)
strcpy(s1, MISC_STATMODE);
@@ -327,7 +327,7 @@ void tell_verbose_status(int idx)
if (backgrd)
strlcpy(s1, MISC_BACKGROUND, sizeof s1);
else {
if (term_z)
if (term_z >= 0)
strlcpy(s1, MISC_TERMMODE, sizeof s1);
else if (con_chan)
strlcpy(s1, MISC_STATMODE, sizeof s1);
@@ -689,7 +689,7 @@ int isowner(char *name) {
*/
void add_hq_user()
{
if (!backgrd && term_z > 0 && userlist) {
if (!backgrd && term_z >= 0 && userlist) {
/* HACK: Workaround using dcc[].nick not to pass literal "-HQ" as a non-const arg */
dcc[term_z].user = get_user_by_handle(userlist, dcc[term_z].nick);
/* Make sure there's an innocuous -HQ user if needed */
@@ -119,10 +119,10 @@ char notify_new[121] = ""; /* Person to send a note to for new users */
int default_flags = 0; /* Default user flags */
int default_uflags = 0; /* Default user-definied flags */
int backgrd = 1; /* Run in the background? */
int con_chan = 0; /* Foreground: constantly display channel stats? */
int term_z = 0; /* Foreground: use the terminal as a partyline? */
int use_stderr = 1; /* Send stuff to stderr instead of logfiles? */
int backgrd = 1; /* Run in the background? */
int con_chan = 0; /* Foreground: constantly display channel stats? */
int term_z = -1; /* Foreground: use the terminal as a partyline? */
int use_stderr = 1; /* Send stuff to stderr instead of logfiles? */
char configfile[121] = "eggdrop.conf"; /* Default config file name */
char pid_file[121]; /* Name of the pid file */
@@ -568,12 +568,12 @@ static void do_arg()
case 'c':
cliflags |= CLI_C;
con_chan = 1;
term_z = 0;
term_z = -1;
break;
case 't':
cliflags |= CLI_T;
con_chan = 0;
term_z = 1;
term_z = 0;
break;
case 'm':
cliflags |= CLI_M;
@@ -1240,12 +1240,12 @@ int main(int arg_c, char **arg_v)
}
/* Terminal emulating dcc chat */
if (!backgrd && term_z) {
if (!backgrd && term_z >= 0) {
/* reuse term_z as glob var to pass it's index in the dcc table around */
term_z = new_dcc(&DCC_CHAT, sizeof(struct chat_info));
/* new_dcc returns -1 on error, and 0 should always be taken by the listening socket */
if (term_z < 1)
/* new_dcc returns -1 on error */
if (term_z < 0)
fatal("ERROR: Failed to initialize foreground chat.", 0);
getvhost(&dcc[term_z].sockname, AF_INET);
@@ -625,7 +625,7 @@ void putlog EGG_VARARGS_DEF(int, arg1)
}
}
}
if (!backgrd && !con_chan && !term_z)
if (!backgrd && !con_chan && term_z < 0)
dprintf(DP_STDOUT, "%s", out);
else if ((type & LOG_MISC) && use_stderr) {
if (shtime)

0 comments on commit eaa07e1

Please sign in to comment.