hood@osiris.cso.uiuc.edu (10/16/88)
Oh boy... this is a big one! This is patch #5 to Pcomm v1.1. This patch will fix: 1) a zillion places where NULL should have been '\0'. 2) two places where it was possible to deference a NULL pointer. 3) the selection-of-the-TTY bug when the index field is used. 4) the bug on shell escape that allowed suspend() to get confused. WARNING: The very first patch is to change the mistake I made in the Doc file patch in Patch #4. Many people have already made that change by hand... if so, be very careful with the first message from patch about "patch already applied, assume reversed?" Emmet P. Gray US Army, HQ III Corps & Fort Hood ...!uunet!uiucuxc!fthood!egray Attn: AFZF-DE-ENV Directorate of Engineering & Housing Environmental Management Office Fort Hood, TX 76544-5057 ------------------------------------------------------------------------------ *** old/Doc Thu Oct 13 09:13:34 1988 --- Doc Thu Oct 13 09:14:32 1988 *************** *** 914,918 will briefly show in the status line. ! NOTE: Pcomm drops the DTR (Data Terminal Ready) before sending the hang up string. --- 914,918 ----- will briefly show in the status line. ! NOTE: Pcomm drops the DTR (Data Terminal Ready) after sending the hang up string. *** old/Doc Thu Oct 13 09:13:34 1988 --- Doc Thu Oct 13 09:14:32 1988 *************** *** 235,239 | Keyboard Macros .. ^A-M Change Directory. ^A-B Pass Thru Mode. ^A-T | | Line Settings .... ^A-P Clear Screen .... ^A-C Directory ..... ^A-F | ! | Exit Pcomm ....... ^A-X Toggle Duplex ... ^A-E Screen Dump ....^A-G | | Unix Gateway ..... ^A-4 Hang Up Phone ... ^A-H Start Data Log. ^A-1 | | Printer On/Off .. ^A-L Toggle Log .... ^A-2 | --- 235,239 ----- | Keyboard Macros .. ^A-M Change Directory. ^A-B Pass Thru Mode. ^A-T | | Line Settings .... ^A-P Clear Screen .... ^A-C Directory ..... ^A-F | ! | Exit Pcomm ....... ^A-X Toggle Duplex ... ^A-E Screen Dump ... ^A-G | | Unix Gateway ..... ^A-4 Hang Up Phone ... ^A-H Start Data Log. ^A-1 | | Printer On/Off .. ^A-L Toggle Log .... ^A-2 | *** old/admin.c Thu Oct 13 07:57:34 1988 --- admin.c Thu Oct 13 07:59:25 1988 *************** *** 31,36 time(&now); date = ctime(&now); ! date[10] = NULL; ! date[16] = NULL; if (!(fp = fopen(LOGFILE, "a+"))) { --- 31,36 ----- time(&now); date = ctime(&now); ! date[10] = '\0'; ! date[16] = '\0'; if (!(fp = fopen(LOGFILE, "a+"))) { *************** *** 61,65 /* if no group, don't bother */ grpbuf = getgrnam(GROUP_NAME); ! if (!grpbuf || !*grpbuf->gr_mem) return(0); /* are you in the group? */ --- 61,65 ----- /* if no group, don't bother */ grpbuf = getgrnam(GROUP_NAME); ! if (grpbuf == NULL || *grpbuf->gr_mem == '\0') return(0); /* are you in the group? */ *************** *** 65,69 /* are you in the group? */ name = getlogin(); ! for (; *grpbuf->gr_mem!=NULL; grpbuf->gr_mem++) { if (!strcmp(*grpbuf->gr_mem, name)) return(0); --- 65,69 ----- /* are you in the group? */ name = getlogin(); ! for (; *grpbuf->gr_mem!='\0'; grpbuf->gr_mem++) { if (!strcmp(*grpbuf->gr_mem, name)) return(0); *************** *** 82,86 } ! if (*number == NULL) { error_win(0, "You are not authorized direct access to the line", "Use the automatic dialing feature"); return(1); --- 82,86 ----- } ! if (*number == '\0') { error_win(0, "You are not authorized direct access to the line", "Use the automatic dialing feature"); return(1); *************** *** 104,108 static char ans[40]; ! temp[0] = NULL; /* add LD codes? */ switch (dir->q_ld[i]) { --- 104,108 ----- static char ans[40]; ! temp[0] = '\0'; /* add LD codes? */ switch (dir->q_ld[i]) { *************** *** 133,137 t++; } ! ans[j] = NULL; return(ans); --- 133,137 ----- t++; } ! ans[j] = '\0'; return(ans); *** old/chg_dir.c Thu Oct 13 07:57:34 1988 --- chg_dir.c Thu Oct 13 07:59:43 1988 *************** *** 31,35 while ((ans = get_str(ch_win, 60, "", " \t\n")) != NULL) { /* a CR means no change */ ! if (*ans == NULL) break; /* expand the input */ --- 31,35 ----- while ((ans = get_str(ch_win, 60, "", " \t\n")) != NULL) { /* a CR means no change */ ! if (*ans == '\0') break; /* expand the input */ *** old/curses.c Thu Oct 13 07:57:34 1988 --- curses.c Thu Oct 13 08:00:34 1988 *************** *** 41,45 } count--; ! buf[count] = NULL; getyx(win, y, x); x--; --- 41,45 ----- } count--; ! buf[count] = '\0'; getyx(win, y, x); x--; *************** *** 55,59 /* illegal character? */ ! if (*disallow != NULL && strchr(disallow, ans)) { beep(); continue; --- 55,59 ----- /* illegal character? */ ! if (*disallow != '\0' && strchr(disallow, ans)) { beep(); continue; *************** *** 59,63 continue; } ! if (*allow != NULL && !strchr(allow, ans)) { beep(); continue; --- 59,63 ----- continue; } ! if (*allow != '\0' && !strchr(allow, ans)) { beep(); continue; *************** *** 74,78 count++; } ! buf[count] = NULL; return(buf); } --- 74,78 ----- count++; } ! buf[count] = '\0'; return(buf); } *************** *** 100,104 } count--; ! buf[count] = NULL; getyx(win, y, x); x--; --- 100,104 ----- } count--; ! buf[count] = '\0'; getyx(win, y, x); x--; *************** *** 128,132 count++; } ! buf[count] = NULL; number = atoi(buf); return(number); --- 128,132 ----- count++; } ! buf[count] = '\0'; number = atoi(buf); return(number); *************** *** 147,151 int do_it; /* if nothing, do nothing */ ! if (str == NULL || *str == NULL) return(0); --- 147,151 ----- int do_it; /* if nothing, do nothing */ ! if (str == NULL || *str == '\0') return(0); *************** *** 197,201 int do_it; ! if (c == NULL) return(0); #ifdef OLDCURSES --- 197,201 ----- int do_it; ! if (c == '\0') return(0); #ifdef OLDCURSES *** old/d_lib.c Thu Oct 13 07:57:34 1988 --- d_lib.c Thu Oct 13 09:06:42 1988 *************** *** 50,54 * Parse the rest of the line. This is similar to using * the "real" strtok() function, but my version returns ! * a null pointer if the parameter is missing. Note the * array of field separators. */ --- 50,54 ----- * Parse the rest of the line. This is similar to using * the "real" strtok() function, but my version returns ! * a pointer to NULL if the parameter is missing. Note the * array of field separators. */ *************** *** 131,135 /* create an empty queue */ for (i=0; i<NUM_QUEUE; i++) { ! d.q_ld[i] = NULL; d.q_num[i] = -1; } --- 131,135 ----- /* create an empty queue */ for (i=0; i<NUM_QUEUE; i++) { ! d.q_ld[i] = '\0'; d.q_num[i] = -1; } *** old/d_manual.c Thu Oct 13 07:57:34 1988 --- d_manual.c Thu Oct 13 09:04:58 1988 *************** *** 35,39 } /* is first char an LD code? */ ! ld_code = NULL; if (strchr("+-@#", *number)) { ld_code = *number; --- 35,39 ----- } /* is first char an LD code? */ ! ld_code = '\0'; if (strchr("+-@#", *number)) { ld_code = *number; *************** *** 50,54 free_ptr(dir->number[0]); dir->name[0] = strdup(number); ! /* if space, change to null */ if (!strcmp(number, " ")) dir->number[0] = null_ptr; --- 50,54 ----- free_ptr(dir->number[0]); dir->name[0] = strdup(number); ! /* if space, change to null_ptr */ if (!strcmp(number, " ")) dir->number[0] = null_ptr; *** old/d_menu.c Thu Oct 13 07:57:34 1988 --- d_menu.c Thu Oct 13 08:03:30 1988 *************** *** 71,75 current = 1; count = 0; ! ld_code = NULL; ret_code = 0; do { --- 71,75 ----- current = 1; count = 0; ! ld_code = '\0'; ret_code = 0; do { *************** *** 96,101 count--; if (!count) ! ld_code = NULL; ! buf[count] = NULL; getyx(dm_win, y, x); x--; --- 96,101 ----- count--; if (!count) ! ld_code = '\0'; ! buf[count] = '\0'; getyx(dm_win, y, x); x--; *************** *** 152,156 */ else { ! buf[count] = NULL; i = atoi(buf); if (!i || i > NUM_DIR) { --- 152,156 ----- */ else { ! buf[count] = '\0'; i = atoi(buf); if (!i || i > NUM_DIR) { *************** *** 302,307 mvwaddstr(win, 19, 21, " "); wmove(win, 19, 21); ! /* a NULL pointer means not active */ ! if (*param->ld_plus != NULL) waddstr(win, "+ "); if (*param->ld_minus != NULL) --- 302,307 ----- mvwaddstr(win, 19, 21, " "); wmove(win, 19, 21); ! /* a pointer to NULL means not active */ ! if (*param->ld_plus != '\0') waddstr(win, "+ "); if (*param->ld_minus != '\0') *************** *** 305,309 if (*param->ld_plus != NULL) waddstr(win, "+ "); ! if (*param->ld_minus != NULL) waddstr(win, "- "); if (*param->ld_at != NULL) --- 305,309 ----- if (*param->ld_plus != '\0') waddstr(win, "+ "); ! if (*param->ld_minus != '\0') waddstr(win, "- "); if (*param->ld_at != '\0') *************** *** 307,311 if (*param->ld_minus != NULL) waddstr(win, "- "); ! if (*param->ld_at != NULL) waddstr(win, "@ "); if (*param->ld_pound != NULL) --- 307,311 ----- if (*param->ld_minus != '\0') waddstr(win, "- "); ! if (*param->ld_at != '\0') waddstr(win, "@ "); if (*param->ld_pound != '\0') *************** *** 309,313 if (*param->ld_at != NULL) waddstr(win, "@ "); ! if (*param->ld_pound != NULL) waddstr(win, "# "); return; --- 309,313 ----- if (*param->ld_at != '\0') waddstr(win, "@ "); ! if (*param->ld_pound != '\0') waddstr(win, "# "); return; *** old/d_print.c Thu Oct 13 07:57:35 1988 --- d_print.c Thu Oct 13 08:04:03 1988 *************** *** 42,46 is_printer = 0; /* the default (printer) */ ! if (*file == NULL) { if (!(fp = popen(LPRINT, "w"))) { sprintf(buf, "'%s'", LPRINT); --- 42,46 ----- is_printer = 0; /* the default (printer) */ ! if (*file == '\0') { if (!(fp = popen(LPRINT, "w"))) { sprintf(buf, "'%s'", LPRINT); *************** *** 135,139 } count--; ! buf[count] = NULL; getyx(win, y, x); x--; --- 135,139 ----- } count--; ! buf[count] = '\0'; getyx(win, y, x); x--; *************** *** 170,174 count++; } ! buf[count] = NULL; return(buf); } --- 170,174 ----- count++; } ! buf[count] = '\0'; return(buf); } *** old/d_prompt.c Thu Oct 13 07:57:35 1988 --- d_prompt.c Thu Oct 13 08:04:32 1988 *************** *** 46,50 if ((ans = get_str(win, 20, "", ";\n")) == NULL) return(0); ! if (*ans != NULL) { strcpy(name, ans); mvwaddstr(win, 2, 5, " "); --- 46,50 ----- if ((ans = get_str(win, 20, "", ";\n")) == NULL) return(0); ! if (*ans != '\0') { strcpy(name, ans); mvwaddstr(win, 2, 5, " "); *************** *** 59,63 if ((ans = get_str(win, 18, "", ";\n")) == NULL) return(0); ! if (*ans != NULL) { strcpy(number, ans); mvwaddstr(win, 2, 26, " "); --- 59,63 ----- if ((ans = get_str(win, 18, "", ";\n")) == NULL) return(0); ! if (*ans != '\0') { strcpy(number, ans); mvwaddstr(win, 2, 26, " "); *************** *** 209,213 if ((ans = get_str(win, 14, "", ";\n")) == NULL) return(0); ! if (*ans != NULL) { strcpy(index, ans); mvwaddstr(win, 2, 62, " "); --- 209,213 ----- if ((ans = get_str(win, 14, "", ";\n")) == NULL) return(0); ! if (*ans != '\0') { strcpy(index, ans); mvwaddstr(win, 2, 62, " "); *** old/d_revise.c Thu Oct 13 07:57:35 1988 --- d_revise.c Fri Oct 14 14:47:39 1988 *************** *** 54,58 continue; } ! buf[count] = NULL; num = atoi(buf); /* valid range of numbers? */ --- 54,58 ----- continue; } ! buf[count] = '\0'; num = atoi(buf); /* valid range of numbers? */ *************** *** 80,84 } count--; ! buf[count] = NULL; getyx(r_win, y, x); x--; --- 80,84 ----- } count--; ! buf[count] = '\0'; getyx(r_win, y, x); x--; *************** *** 163,167 /* * Prompt for long distance code changes. If new string is a space, ! * change it to a null pointer. Returns the new value or NULL on escape. */ --- 163,167 ----- /* * Prompt for long distance code changes. If new string is a space, ! * change it to null_ptr. Returns the new value or NULL on escape. */ *************** *** 182,186 if ((ans = get_str(win, 20, "", "\n")) == NULL) return(NULL); ! /* if space, change to NULL pointer */ if (!strcmp(ans, " ")) ans = null_ptr; --- 182,186 ----- if ((ans = get_str(win, 20, "", "\n")) == NULL) return(NULL); ! /* if space, change to null_ptr */ if (!strcmp(ans, " ")) ans = null_ptr; *** old/data_log.c Thu Oct 13 07:57:35 1988 --- data_log.c Thu Oct 13 08:05:54 1988 *************** *** 36,40 while ((ans = get_str(dl_win, 60, "", " \t\n")) != NULL) { /* give 'em the default */ ! if (*ans == NULL) path = strdup(param->logfile); else --- 36,40 ----- while ((ans = get_str(dl_win, 60, "", " \t\n")) != NULL) { /* give 'em the default */ ! if (*ans == '\0') path = strdup(param->logfile); else *** old/di_win.c Thu Oct 13 07:57:36 1988 --- di_win.c Thu Oct 13 08:06:59 1988 *************** *** 45,49 return(0); /* ! * If the phone number is a NULL, then either we are on a * direct line, or you want to do the dialing yourself. */ --- 45,49 ----- return(0); /* ! * If the phone number points to NULL, then either we are on a * direct line, or you want to do the dialing yourself. */ *************** *** 48,52 * direct line, or you want to do the dialing yourself. */ ! if (*dir->number[dir->q_num[0]] == NULL) { /* check LD permission */ if (limit_ld(0)) --- 48,52 ----- * direct line, or you want to do the dialing yourself. */ ! if (*dir->number[dir->q_num[0]] == '\0') { /* check LD permission */ if (limit_ld(0)) *************** *** 88,92 time(&now); tbuf = ctime(&now); ! tbuf[19] = NULL; mvwaddstr(di_win, 7, 36, &tbuf[11]); --- 88,92 ----- time(&now); tbuf = ctime(&now); ! tbuf[19] = '\0'; mvwaddstr(di_win, 7, 36, &tbuf[11]); *************** *** 313,317 time(&now); tbuf = ctime(&now); ! tbuf[19] = NULL; mvwaddstr(win, 8, 36, &tbuf[11]); /* the index field */ --- 313,317 ----- time(&now); tbuf = ctime(&now); ! tbuf[19] = '\0'; mvwaddstr(win, 8, 36, &tbuf[11]); /* the index field */ *************** *** 363,367 } ! if (*str == NULL) return(0); /* test "str" against all others */ --- 363,367 ----- } ! if (*str == '\0') return(0); /* test "str" against all others */ *** old/dial.c Thu Oct 13 07:57:36 1988 --- dial.c Thu Oct 13 09:00:15 1988 *************** *** 36,40 * codes are added if they are requested. */ ! s[0] = NULL; strcpy(s, modem->dial[modem->m_cur]); --- 36,40 ----- * codes are added if they are requested. */ ! s[0] = '\0'; strcpy(s, modem->dial[modem->m_cur]); *************** *** 75,79 skip = 0; } ! number[i] = NULL; /* add it to the string */ strcat(s, number); --- 75,79 ----- skip = 0; } ! number[i] = '\0'; /* add it to the string */ strcat(s, number); *************** *** 137,141 unsigned int sleep(); /* empty string? */ ! if (s == NULL || *s == NULL) return; --- 137,141 ----- unsigned int sleep(); /* empty string? */ ! if (s == NULL || *s == '\0') return; *************** *** 178,182 s++; /* premature EOF? */ ! if (*s == NULL) break; /* upper and lower case */ --- 178,182 ----- s++; /* premature EOF? */ ! if (*s == '\0') break; /* upper and lower case */ *************** *** 224,228 { extern int fd; ! char c; #ifdef UNIXPC unsigned int sleep(); --- 224,228 ----- { extern int fd; ! int c; #ifdef UNIXPC unsigned int sleep(); *************** *** 247,251 /* search for key words */ for (; rc_index<511; rc_index++) { ! if ((int) (c = getc_line(1)) <= 0) return(NULL); #ifdef DEBUG --- 247,251 ----- /* search for key words */ for (; rc_index<511; rc_index++) { ! if ((c = getc_line(1)) <= 0) return(NULL); #ifdef DEBUG *************** *** 254,258 rc_buf[rc_index] = c; ! rc_buf[rc_index+1] = NULL; /* the connect strings */ if (match(rc_buf, modem->con_3[modem->m_cur])) --- 254,258 ----- rc_buf[rc_index] = c; ! rc_buf[rc_index+1] = '\0'; /* the connect strings */ if (match(rc_buf, modem->con_3[modem->m_cur])) *************** *** 304,308 char new[40]; /* if no string to match */ ! if (*s2 == NULL) return(0); /* translate synonyms */ --- 304,308 ----- char new[40]; /* if no string to match */ ! if (*s2 == '\0') return(0); /* translate synonyms */ *************** *** 330,334 if (*s2 == param->ctrl_char) { s2++; ! if (*s2 == NULL) break; if (*s2 > '_') --- 330,334 ----- if (*s2 == param->ctrl_char) { s2++; ! if (*s2 == '\0') break; if (*s2 > '_') *************** *** 344,348 s2++; } ! new[i] = NULL; diff = strlen(s1) - strlen(new); --- 344,348 ----- s2++; } ! new[i] = '\0'; diff = strlen(s1) - strlen(new); *** old/expand.c Thu Oct 13 07:57:36 1988 --- expand.c Thu Oct 13 08:08:16 1988 *************** *** 23,27 if (input == NULL) return(NULL); ! if (*input == NULL) return(null_ptr); /* any thing to expand? */ --- 23,27 ----- if (input == NULL) return(NULL); ! if (*input == '\0') return(null_ptr); /* any thing to expand? */ *************** *** 47,51 return(ans); else ! buf[last] = NULL; free_ptr(ans); --- 47,51 ----- return(ans); else ! buf[last] = '\0'; free_ptr(ans); *************** *** 74,78 /* get the environmental variable */ shellpath = getenv("SHELL"); ! if (shellpath == NULL || *shellpath == NULL) shellpath = "/bin/sh"; --- 74,78 ----- /* get the environmental variable */ shellpath = getenv("SHELL"); ! if (shellpath == NULL || *shellpath == '\0') shellpath = "/bin/sh"; *** old/getcwd.c Thu Oct 13 07:57:37 1988 --- getcwd.c Thu Oct 13 08:08:24 1988 *************** *** 19,23 pclose(pfp); /* zap the new line */ ! buf[strlen(buf)-1] = NULL; return(buf); } --- 19,23 ----- pclose(pfp); /* zap the new line */ ! buf[strlen(buf)-1] = '\0'; return(buf); } *** old/getopt.c Thu Oct 13 07:57:37 1988 --- getopt.c Thu Oct 13 08:09:15 1988 *************** *** 21,25 if (optind >= argc || argv[optind][0] != '-' || argv[optind][1] == '\0') return(EOF); ! else if (strcmp(argv[optind], "--") == NULL) { optind++; return(EOF); --- 21,25 ----- if (optind >= argc || argv[optind][0] != '-' || argv[optind][1] == '\0') return(EOF); ! else if (strcmp(argv[optind], "--") == 0) { optind++; return(EOF); *** old/info.c Thu Oct 13 07:57:38 1988 --- info.c Thu Oct 13 09:12:30 1988 *************** *** 5,9 #define VERSION "1.1" ! #define DATE "30 Sep 88" #include <stdio.h> --- 5,9 ----- #define VERSION "1.1" ! #define DATE "15 Oct 88" #include <stdio.h> *** old/init.c Thu Oct 13 07:57:38 1988 --- init.c Sat Oct 15 19:57:45 1988 *************** *** 26,30 extern int shm_id; char *shmat(); ! void exit(); /* --- 26,30 ----- extern int shm_id; char *shmat(); ! void perror(), exit(); /* *************** *** 68,72 for (j=0; j<COLS; j++) s_ptr->vs[i][j] = ' '; ! s_ptr->vs[i][COLS] = NULL; } #else /* SHAREDMEM */ --- 68,72 ----- for (j=0; j<COLS; j++) s_ptr->vs[i][j] = ' '; ! s_ptr->vs[i][COLS] = '\0'; } #else /* SHAREDMEM */ *************** *** 98,102 /* see if PCOMM variable is set */ pcomm = getenv("PCOMM"); ! if (pcomm == NULL || *pcomm == NULL) pcomm = NULL; else { --- 98,102 ----- /* see if PCOMM variable is set */ pcomm = getenv("PCOMM"); ! if (pcomm == NULL || *pcomm == '\0') pcomm = NULL; else { *************** *** 103,107 /* zap the trailing separator */ if (pcomm[strlen(pcomm)-1] == '/') ! pcomm[strlen(pcomm)-1] = NULL; } --- 103,107 ----- /* zap the trailing separator */ if (pcomm[strlen(pcomm)-1] == '/') ! pcomm[strlen(pcomm)-1] = '\0'; } *** old/input.c Thu Oct 13 07:57:39 1988 --- input.c Sat Oct 15 19:58:09 1988 *************** *** 51,55 { FILE *popen(); ! int got_sig(); char c, *strcpy(); void _exit(), exit(), vcs_table(); --- 51,55 ----- { FILE *popen(); ! int c1, got_sig(); char c, *strcpy(); void _exit(), exit(), vcs_table(); *************** *** 57,60 int shm_id; char *shmat(); #endif /* SHAREDMEM */ /* set the trap for the signals */ --- 57,61 ----- int shm_id; char *shmat(); + void perror(); #endif /* SHAREDMEM */ /* set the trap for the signals */ *************** *** 193,197 while (1) { ! if ((int) (c = readbyte()) <= 0) continue; /* send to logfile */ --- 194,198 ----- while (1) { ! if ((c1 = readbyte()) <= 0) continue; c = c1; *************** *** 195,198 if ((int) (c = readbyte()) <= 0) continue; /* send to logfile */ if (status->log) { --- 196,200 ----- if ((c1 = readbyte()) <= 0) continue; + c = c1; /* send to logfile */ if (status->log) { *************** *** 390,394 for (i=0; i<max_row; i++) { ! VS[i][max_col] = NULL; fprintf(fp, "%s\n", VS[i]); } --- 392,396 ----- for (i=0; i<max_row; i++) { ! VS[i][max_col] = '\0'; fprintf(fp, "%s\n", VS[i]); } *************** *** 422,426 for (i=0; i<max_row; i++) { fgets(VS[i], MAX_COL+2, fp); ! VS[i][max_col] = NULL; } fclose(fp); --- 424,428 ----- for (i=0; i<max_row; i++) { fgets(VS[i], MAX_COL+2, fp); ! VS[i][max_col] = '\0'; } fclose(fp); *************** *** 440,444 for (i=0; i<max_row; i++) { ! VS[i][max_col] = NULL; for (j=0; j<max_col; j++) VS[i][j] = ' '; --- 442,446 ----- for (i=0; i<max_row; i++) { ! VS[i][max_col] = '\0'; for (j=0; j<max_col; j++) VS[i][j] = ' '; *** old/m_lib.c Thu Oct 13 07:57:39 1988 --- m_lib.c Thu Oct 13 09:07:31 1988 *************** *** 56,60 /* * This is similar to the "real" strtok() command ! * but this one returns a null pointer on a missing * attribute. Note the use of the field separator * array. --- 56,60 ----- /* * This is similar to the "real" strtok() command ! * but this one returns a pointer to NULL on a missing * attribute. Note the use of the field separator * array. *** old/macro.c Thu Oct 13 07:57:39 1988 --- macro.c Thu Oct 13 08:52:56 1988 *************** *** 179,186 wrefresh(mp_win); ! new = get_str(mp_win, 50, "", "\n"); ! /* if space, change to NULL pointer */ ! if (!strcmp(new, " ")) ! new = null_ptr; werase(mp_win); --- 179,190 ----- wrefresh(mp_win); ! if ((new = get_str(mp_win, 50, "", "\n")) != NULL) { ! /* if CR, return NULL */ ! if (*new == '\0') ! new = NULL; ! /* if space, change to null_ptr */ ! else if (!strcmp(new, " ")) ! new = null_ptr; ! } werase(mp_win); *** old/main.c Thu Oct 13 07:57:39 1988 --- main.c Thu Oct 13 09:12:04 1988 *************** *** 21,24 * patch #3 19 Sep 88 * patch #4 30 Sep 88 */ --- 21,25 ----- * patch #3 19 Sep 88 * patch #4 30 Sep 88 + * patch #5 15 Oct 88 */ *************** *** 100,104 /* get terminal type */ term = getenv("TERM"); ! if (term == NULL || *term == NULL) { fprintf(stderr, "Windows not supported (TERM not defined)\n"); exit(1); --- 101,105 ----- /* get terminal type */ term = getenv("TERM"); ! if (term == NULL || *term == '\0') { fprintf(stderr, "Windows not supported (TERM not defined)\n"); exit(1); *************** *** 220,224 /* dissect the path component */ if (p = strrchr(path, '/')) ! *(p++) = NULL; else strcpy(path, "."); --- 221,225 ----- /* dissect the path component */ if (p = strrchr(path, '/')) ! *(p++) = '\0'; else strcpy(path, "."); *** old/n_shell.c Thu Oct 13 07:57:39 1988 --- n_shell.c Thu Oct 13 21:46:38 1988 *************** *** 27,31 shellpath = getenv("SHELL"); ! if (shellpath == NULL || *shellpath == NULL) shellpath = "/bin/sh"; --- 27,31 ----- shellpath = getenv("SHELL"); ! if (shellpath == NULL || *shellpath == '\0') shellpath = "/bin/sh"; *** old/pexit.c Thu Oct 13 07:57:40 1988 --- pexit.c Sat Oct 15 19:58:26 1988 *************** *** 54,57 #ifdef SHAREDMEM extern int shm_id; #endif /* SHAREDMEM */ /* kill the input routine */ --- 54,58 ----- #ifdef SHAREDMEM extern int shm_id; + void perror(); #endif /* SHAREDMEM */ /* kill the input routine */ *** old/port.c Thu Oct 13 07:57:40 1988 --- port.c Fri Oct 14 09:20:49 1988 *************** *** 29,33 extern int fd; register int i; ! int j, k, lfd, list[NUM_TTY], cmask, tbaud; char file[80], buf[80], message[80], *strdup(); unsigned int sleep(); --- 29,33 ----- extern int fd; register int i; ! int j, k, lfd, list[NUM_TTY], cmask, tbaud, is_dev; char file[80], buf[80], message[80], *strdup(); unsigned int sleep(); *************** *** 38,41 #endif /* ASCII_PID */ /* * If we already have a port, see if it is good enough for the --- 38,42 ----- #endif /* ASCII_PID */ + is_dev = chk_index(dir->index[dir->d_cur]); /* * If we already have a port, see if it is good enough for the *************** *** 45,49 if (fd != -1) { if (!strcmp(dir->index[dir->d_cur], modem->tty[modem->t_cur]) || ! ck_speed(modem->t_cur, dir->baud[dir->d_cur])) { /* * Reset the line because the baud rate (or other --- 46,50 ----- if (fd != -1) { if (!strcmp(dir->index[dir->d_cur], modem->tty[modem->t_cur]) || ! (!is_dev && ck_speed(modem->t_cur, dir->baud[dir->d_cur]))) { /* * Reset the line because the baud rate (or other *************** *** 62,70 * dialing directory is a valid device name, then use that TTY. */ ! if (*dir->index[dir->d_cur] != NULL) { ! sprintf(buf, "/dev/%s", dir->index[dir->d_cur]); ! /* if index is a valid device */ ! if (!access(buf, 0)) { ! for (i=0; i<modem->t_entries; i++) { /* and it exists in modem database */ if (!strcmp(dir->index[dir->d_cur], modem->tty[i])) { --- 63,68 ----- * dialing directory is a valid device name, then use that TTY. */ ! if (is_dev) { ! for (i=0; i<modem->t_entries; i++) { /* and it exists in modem database */ if (!strcmp(dir->index[dir->d_cur], modem->tty[i])) { *************** *** 68,76 for (i=0; i<modem->t_entries; i++) { /* and it exists in modem database */ ! if (!strcmp(dir->index[dir->d_cur], modem->tty[i])) { ! list[0] = i; ! list[1] = -1; ! break; ! } } } --- 66,73 ----- for (i=0; i<modem->t_entries; i++) { /* and it exists in modem database */ ! if (!strcmp(dir->index[dir->d_cur], modem->tty[i])) { ! list[0] = i; ! list[1] = -1; ! break; } } *************** *** 75,78 } } } --- 72,80 ----- } } + if (list[0] == -1) { + sprintf(message, "'%' in the index field doesn't exist in the", dir->index[dir->d_cur]); + sprintf(buf, "modem/TTY database '%s'", modem->m_path); + error_win(0, message, buf); + } } *************** *** 214,218 } /* remove the lock */ ! if (lock_path != NULL && *lock_path != NULL) { if (unlink(lock_path)) { sprintf(buf, "'%s'", lock_path); --- 216,220 ----- } /* remove the lock */ ! if (lock_path != NULL && *lock_path != '\0') { if (unlink(lock_path)) { sprintf(buf, "'%s'", lock_path); *************** *** 367,371 switch (baud) { case 300: ! if (*modem->con_3[mod] != NULL) return(1); break; --- 369,373 ----- switch (baud) { case 300: ! if (*modem->con_3[mod] != '\0') return(1); break; *************** *** 371,375 break; case 1200: ! if (*modem->con_12[mod] != NULL) return(1); break; --- 373,377 ----- break; case 1200: ! if (*modem->con_12[mod] != '\0') return(1); break; *************** *** 375,379 break; case 2400: ! if (*modem->con_24[mod] != NULL) return(1); break; --- 377,381 ----- break; case 2400: ! if (*modem->con_24[mod] != '\0') return(1); break; *************** *** 379,383 break; case 4800: ! if (*modem->con_48[mod] != NULL) return(1); break; --- 381,385 ----- break; case 4800: ! if (*modem->con_48[mod] != '\0') return(1); break; *************** *** 383,387 break; case 9600: ! if (*modem->con_96[mod] != NULL) return(1); break; --- 385,389 ----- break; case 9600: ! if (*modem->con_96[mod] != '\0') return(1); break; *************** *** 387,391 break; case 19200: ! if (*modem->con_192[mod] != NULL) return(1); break; --- 389,393 ----- break; case 19200: ! if (*modem->con_192[mod] != '\0') return(1); break; *************** *** 391,394 break; } return(0); } --- 393,417 ----- break; } + return(0); + } + + /* + * Check to see if the index field is a valid device name. + */ + + static int + chk_index(index) + char *index; + { + char buf[80], *strcpy(), *strcat(); + + if (*index == '\0') + return(0); + + strcpy(buf, "/dev/"); + strcat(buf, index); + + if (!access(buf, 0)) + return(1); return(0); } *** old/redial.c Thu Oct 13 07:57:40 1988 --- redial.c Thu Oct 13 08:15:03 1988 *************** *** 33,37 while ((ans = get_str(rd_win, 35, "0123456789+-@# ", "")) != NULL) { oops = 0; ! if (*ans == NULL) { /* use previous queue */ if (dir->q_num[0] != -1) { --- 33,37 ----- while ((ans = get_str(rd_win, 35, "0123456789+-@# ", "")) != NULL) { oops = 0; ! if (*ans == '\0') { /* use previous queue */ if (dir->q_num[0] != -1) { *************** *** 52,56 entry = strtok(ans, " "); for (i=0; i<NUM_QUEUE; i++) { ! if (*entry == NULL) { dir->q_num[i] = -1; continue; --- 52,56 ----- entry = strtok(ans, " "); for (i=0; i<NUM_QUEUE; i++) { ! if (*entry == '\0') { dir->q_num[i] = -1; continue; *************** *** 57,61 } /* is there a LD code? */ ! dir->q_ld[i] = NULL; if (strchr("+-@#", *entry)) { dir->q_ld[i] = *entry; --- 57,61 ----- } /* is there a LD code? */ ! dir->q_ld[i] = '\0'; if (strchr("+-@#", *entry)) { dir->q_ld[i] = *entry; *** old/s_gen.c Thu Oct 13 07:57:40 1988 --- s_gen.c Sat Oct 15 19:56:48 1988 *************** *** 70,74 break; case 4: ! if ((c = chr_prompt(g_win, 8, 50, "Pause character", "1 second")) != NULL) { param->pause_char = c; ret_code++; --- 70,74 ----- break; case 4: ! if ((c = chr_prompt(g_win, 8, 50, "Pause character", "1 second")) != '\0') { param->pause_char = c; ret_code++; *************** *** 76,80 break; case 5: ! if ((c = chr_prompt(g_win, 9, 50, "CR character", "(carriage return)")) != NULL) { param->cr_char = c; ret_code++; --- 76,80 ----- break; case 5: ! if ((c = chr_prompt(g_win, 9, 50, "CR character", "(carriage return)")) != '\0') { param->cr_char = c; ret_code++; *************** *** 82,86 break; case 6: ! if ((c = chr_prompt(g_win, 10, 50, "CTRL character", "(control)")) != NULL) { param->ctrl_char = c; ret_code++; --- 82,86 ----- break; case 6: ! if ((c = chr_prompt(g_win, 10, 50, "CTRL character", "(control)")) != '\0') { param->ctrl_char = c; ret_code++; *************** *** 88,92 break; case 7: ! if ((c = chr_prompt(g_win, 11, 50, "ESC character", "(escape)")) != NULL) { param->esc_char = c; ret_code++; --- 88,92 ----- break; case 7: ! if ((c = chr_prompt(g_win, 11, 50, "ESC character", "(escape)")) != '\0') { param->esc_char = c; ret_code++; *************** *** 94,98 break; case 8: ! if ((c = chr_prompt(g_win, 12, 50, "Break character", "")) != NULL) { param->brk_char = c; ret_code++; --- 94,98 ----- break; case 8: ! if ((c = chr_prompt(g_win, 12, 50, "Break character", "")) != '\0') { param->brk_char = c; ret_code++; *** old/s_modem.c Thu Oct 13 07:57:41 1988 --- s_modem.c Thu Oct 13 08:16:54 1988 *************** *** 186,190 while ((ans = wgetch(win)) != '\r') { i++; ! if (*modem->mname[i] == NULL) i = 0; if (ans == ESC) --- 186,190 ----- while ((ans = wgetch(win)) != '\r') { i++; ! if (*modem->mname[i] == '\0') i = 0; if (ans == ESC) *** old/s_prompt.c Thu Oct 13 07:57:41 1988 --- s_prompt.c Sat Oct 15 19:57:13 1988 *************** *** 58,62 if ((ans = get_str(win, 1, "", "\n")) == NULL) ! return(NULL); /* display the value in bold */ mvwaddstr(win, y, x, " "); --- 58,62 ----- if ((ans = get_str(win, 1, "", "\n")) == NULL) ! return('\0'); /* display the value in bold */ mvwaddstr(win, y, x, " "); *** old/screen.c Thu Oct 13 07:57:41 1988 --- screen.c Thu Oct 13 08:18:38 1988 *************** *** 87,91 while (fgets(buf, MAX_COL+2, fp) != NULL) { /* zap the line feed */ ! buf[COLS] = NULL; mvaddstr(i++, 0, buf); } --- 87,91 ----- while (fgets(buf, MAX_COL+2, fp) != NULL) { /* zap the line feed */ ! buf[COLS] = '\0'; mvaddstr(i++, 0, buf); } *** old/st_line.c Thu Oct 13 07:57:41 1988 --- st_line.c Thu Oct 13 08:18:57 1988 *************** *** 46,50 * what's going on in the status line. */ ! if (*message == NULL) sprintf(field_one, " %4.4s-0 HELP ", param->ascii_hot); else --- 46,50 ----- * what's going on in the status line. */ ! if (*message == '\0') sprintf(field_one, " %4.4s-0 HELP ", param->ascii_hot); else *** old/strings.c Thu Oct 13 07:57:41 1988 --- strings.c Thu Oct 13 09:09:57 1988 *************** *** 21,25 return(NULL); /* if pointer to null */ ! if (*str == NULL) return(null_ptr); --- 21,25 ----- return(NULL); /* if pointer to null */ ! if (*str == '\0') return(null_ptr); *************** *** 47,53 /* ! * This routine is similar to strtok(3). But our version handles null ! * strings and takes a single separator character as an argument. ! * Returns a NULL on end of string or error. */ --- 47,53 ----- /* ! * This routine is similar to strtok(3). But this version handles missing ! * tokens by returning a pointer to NULL. Also, it takes a single separator ! * character as an argument. Returns a NULL on end of string or error. */ *************** *** 56,60 char *str, c; { - extern char *null_ptr; char *strchr(); static char *ptr, *sep; --- 56,59 ----- char *str, c; { char *strchr(); static char *ptr, *sep; *************** *** 65,69 ptr = sep; /* at the end? */ ! if (*ptr == NULL) return(NULL); /* no separator? */ --- 64,68 ----- ptr = sep; /* at the end? */ ! if (*ptr == '\0') return(NULL); /* no separator? */ *************** *** 71,75 return(NULL); /* zap the sep, move past it */ ! *sep = NULL; sep++; --- 70,74 ----- return(NULL); /* zap the sep, move past it */ ! *sep = '\0'; sep++; *** old/terminal.c Thu Oct 13 07:57:42 1988 --- terminal.c Fri Oct 14 08:08:59 1988 *************** *** 365,368 /* fork the input routine */ if (!(pid = fork())) { #ifdef SETUGID setuid(getuid()); --- 365,369 ----- /* fork the input routine */ if (!(pid = fork())) { + setpgrp(); #ifdef SETUGID setuid(getuid()); *** old/vcs.c Thu Oct 13 07:57:42 1988 --- vcs.c Thu Oct 13 08:20:40 1988 *************** *** 323,327 /* where are they different */ i = 0; ! while (buf[i] != NULL) { if (buf[i] != putc_buf[i]) break; --- 323,327 ----- /* where are they different */ i = 0; ! while (buf[i] != '\0') { if (buf[i] != putc_buf[i]) break; *************** *** 329,333 } /* sanity checking */ ! if (buf[i] == NULL) temp[0] = -1; /* if add, what is offset? */ --- 329,333 ----- } /* sanity checking */ ! if (buf[i] == '\0') temp[0] = -1; /* if add, what is offset? */ *************** *** 348,352 /* where are they different */ i = 0; ! while (buf[i] != NULL) { if (buf[i] != putc_buf[i]) break; --- 348,352 ----- /* where are they different */ i = 0; ! while (buf[i] != '\0') { if (buf[i] != putc_buf[i]) break; *************** *** 354,358 } temp[i] = 1001; ! if (buf[i] == NULL) temp[0] = -1; } --- 354,358 ----- } temp[i] = 1001; ! if (buf[i] == '\0') temp[0] = -1; } *************** *** 442,446 putc_cnt = 0; ! putc_buf[0] = NULL; tputs(s, 1, fake_putc); putc_buf[putc_cnt] = NULL; --- 442,446 ----- putc_cnt = 0; ! putc_buf[0] = '\0'; tputs(s, 1, fake_putc); putc_buf[putc_cnt] = '\0'; *************** *** 444,448 putc_buf[0] = NULL; tputs(s, 1, fake_putc); ! putc_buf[putc_cnt] = NULL; return; } --- 444,448 ----- putc_buf[0] = '\0'; tputs(s, 1, fake_putc); ! putc_buf[putc_cnt] = '\0'; return; } *** old/x_ascii.c Thu Oct 13 07:57:42 1988 --- x_ascii.c Thu Oct 13 09:03:36 1988 *************** *** 300,305 unsigned int sec; { ! int bl_force(); ! char c; unsigned int alarm(); --- 300,304 ----- unsigned int sec; { ! int c, bl_force(); unsigned int alarm(); *************** *** 308,312 alarm(sec); ! if ((int) (c = buf_read()) < 0) { alarm(0); return(-1); --- 307,311 ----- alarm(sec); ! if ((c = buf_read()) < 0) { alarm(0); return(-1); *************** *** 315,319 return(-1); alarm(0); ! return(c & 0xff); } /*ARGSUSED*/ --- 314,318 ----- return(-1); alarm(0); ! return(c); } /*ARGSUSED*/ *** old/x_batch.c Thu Oct 13 07:57:42 1988 --- x_batch.c Thu Oct 13 08:22:10 1988 *************** *** 154,158 } } ! temp_name[12] = NULL; /* send our checksum */ sum = calc_sum((unsigned char *) temp_name, 12); --- 154,158 ----- } } ! temp_name[12] = '\0'; /* send our checksum */ sum = calc_sum((unsigned char *) temp_name, 12); *************** *** 190,194 /* start with a clean block */ for (i=0; i<132; i++) ! buf[i] = NULL; /* the header */ buf[0] = SOH; --- 190,194 ----- /* start with a clean block */ for (i=0; i<132; i++) ! buf[i] = '\0'; /* the header */ buf[0] = SOH; *************** *** 201,205 * marker is an empty block. */ ! if (*file != NULL) { strcpy((char *) &buf[3], file); sprintf((char *) &buf[strlen(file)+4], "%ld", size); --- 201,205 ----- * marker is an empty block. */ ! if (*file != '\0') { strcpy((char *) &buf[3], file); sprintf((char *) &buf[strlen(file)+4], "%ld", size); *************** *** 232,236 file_length = 0L; ! file_name[0] = NULL; /* read the zero block */ if (code = rcv_block(win, 1, 1024, 0)) --- 232,236 ----- file_length = 0L; ! file_name[0] = '\0'; /* read the zero block */ if (code = rcv_block(win, 1, 1024, 0)) *************** *** 237,241 return(code); /* at end of batch */ ! if (buf[3] == NULL) return(0); /* get the file name */ --- 237,241 ----- return(code); /* at end of batch */ ! if (buf[3] == '\0') return(0); /* get the file name */ *************** *** 242,246 change_name(win, (char *) &buf[3]); /* any trouble? */ ! if (file_name[0] == NULL) { putc_line(CAN); return(0); --- 242,246 ----- change_name(win, (char *) &buf[3]); /* any trouble? */ ! if (file_name[0] == '\0') { putc_line(CAN); return(0); *************** *** 279,283 strcpy(ans, temp); ! file_name[0] = NULL; /* write permission on directory? */ if (access(".", 2)) { --- 279,283 ----- strcpy(ans, temp); ! file_name[0] = '\0'; /* write permission on directory? */ if (access(".", 2)) { *************** *** 306,310 strcpy(temp, "X"); strncat(temp, ans, 13); ! temp[14] = NULL; strcpy(ans, temp); } --- 306,310 ----- strcpy(temp, "X"); strncat(temp, ans, 13); ! temp[14] = '\0'; strcpy(ans, temp); } *************** *** 341,345 if (*s == '.' && !dot) { dot++; ! *s = NULL; ext = s + 1; } --- 341,345 ----- if (*s == '.' && !dot) { dot++; ! *s = '\0'; ext = s + 1; } *************** *** 348,352 } /* if null name component */ ! if (*name == NULL) name = "X"; /* if name too long */ --- 348,352 ----- } /* if null name component */ ! if (*name == '\0') name = "X"; /* if name too long */ *************** *** 352,356 /* if name too long */ if (strlen(name) > 8) ! *(name+8) = NULL; /* if extension too long */ if (strlen(ext) > 3) --- 352,356 ----- /* if name too long */ if (strlen(name) > 8) ! *(name+8) = '\0'; /* if extension too long */ if (strlen(ext) > 3) *************** *** 355,359 /* if extension too long */ if (strlen(ext) > 3) ! *(ext+3) = NULL; sprintf(ans, "%-8.8s%-3.3s%c", temp, ext, CTRLZ); --- 355,359 ----- /* if extension too long */ if (strlen(ext) > 3) ! *(ext+3) = '\0'; sprintf(ans, "%-8.8s%-3.3s%c", temp, ext, CTRLZ); *************** *** 375,379 char temp[15]; ! file_name[0] = NULL; if (!*cpm_name) return; --- 375,379 ----- char temp[15]; ! file_name[0] = '\0'; if (!*cpm_name) return; *************** *** 404,408 } } ! file_name[n] = NULL; return; } --- 404,408 ----- } } ! file_name[n] = '\0'; return; } *** old/x_extrnl.c Thu Oct 13 07:57:42 1988 --- x_extrnl.c Thu Oct 13 08:22:25 1988 *************** *** 33,37 shellpath = getenv("SHELL"); ! if (shellpath == NULL || *shellpath == NULL) shellpath = "/bin/sh"; --- 33,37 ----- shellpath = getenv("SHELL"); ! if (shellpath == NULL || *shellpath == '\0') shellpath = "/bin/sh"; *** old/x_menu.c Thu Oct 13 07:57:42 1988 --- x_menu.c Thu Oct 13 08:42:35 1988 *************** *** 146,150 ans = get_str(gn_win, 60, "", " \t\n"); ! if (ans == NULL || *ans == NULL) { list = NULL; break; --- 146,150 ----- ans = get_str(gn_win, 60, "", " \t\n"); ! if (ans == NULL || *ans == '\0') { list = NULL; break; *************** *** 251,256 /* get the line */ ans = get_str(ge_win, 60, "", "\n"); ! cmd = expand(ans); ! if (*cmd == NULL) cmd = NULL; --- 251,255 ----- /* get the line */ ans = get_str(ge_win, 60, "", "\n"); ! if (ans == NULL || *ans == '\0') cmd = NULL; else *************** *** 254,257 if (*cmd == NULL) cmd = NULL; werase(ge_win); --- 253,258 ----- if (ans == NULL || *ans == '\0') cmd = NULL; + else + cmd = expand(ans); werase(ge_win); *** old/x_rcv.c Thu Oct 13 07:57:42 1988 --- x_rcv.c Thu Oct 13 08:26:13 1988 *************** *** 104,108 /* at the end? */ ! if (buf[3] == NULL) { beep(); wrefresh(win); --- 104,108 ----- /* at the end? */ ! if (buf[3] == '\0') { beep(); wrefresh(win); *************** *** 114,118 } /* any trouble? */ ! if (file_name[0] == NULL) continue; --- 114,118 ----- } /* any trouble? */ ! if (file_name[0] == '\0') continue;