fix to time-of-day check in uucico (4.2BSD)
Dave Martindale
dmmartindale at watmath.UUCP
Wed Jan 16 14:52:14 AEST 1985
Index: usr.bin/uucp/conn.c 4.2BSD
Description:
The code in conn.c that checks if the current time is within
the window allowed in L.sys gets the boundary check wrong if
the allowed call times cross midnight.
Repeat-By:
Set up an L.sys entry of "Any2300-0800". Try to call between
2300 and 2301.
Fix:
Basically, the existing code is too cute for its own good.
Replace it with the code below which is shorter, easier to read,
and even executes faster.
*** /tmp/conn.c Tue Jan 15 23:29:18 1985
--- conn.c Tue Jan 15 23:39:43 1985
***************
*** 857,863
};
time_t clock;
int rtime;
! int i, tl, th, tn, flag, dayok=0;
struct tm *localtime();
struct tm *tp;
char *index();
--- 857,863 -----
};
time_t clock;
int rtime;
! int i, tl, th, tn, dayok=0;
struct tm *localtime();
struct tm *tp;
char *index();
***************
*** 898,912
tn = tp->tm_hour * 100 + tp->tm_min;
if (i < 2)
return(1);
! if (th < tl)
! flag = 0; /* set up for crossover 2400 test */
! else
! flag = 1;
! if ((tn >= tl && tn <= th)
! || (tn >= th && tn <= tl)) /* test for crossover 2400 */
! return(flag);
! else
! return(!flag);
}
--- 898,909 -----
tn = tp->tm_hour * 100 + tp->tm_min;
if (i < 2)
return(1);
! if (th < tl) { /* crosses midnight */
! if (tl <= tn || tn < th)
! return(1);
! } else
! if (tl <= tn && tn < th)
! return(1);
}
More information about the Comp.bugs.4bsd.ucb-fixes
mailing list