Re: [patch] which(1): out of bounds read
Max Fillinger wrote: >If PATH starts with "/:", which(1) reads outside of allocated memory. >Maybe that caused the non-reproduceable coredump mentioned in [0]? I think you're right as I did have / at the beginning of my PATH when which(1) coredumped on me. I was planning to look at it today but you beat me to it :-) Philippe
[patch] which(1): out of bounds read
If PATH starts with "/:", which(1) reads outside of allocated memory. Maybe that caused the non-reproduceable coredump mentioned in [0]? The function progname sets path = strdup(path) and pathcpy = path and runs the following loop: > while ((p = strsep(&pathcpy, ":")) != NULL) { > if (*p == '\0') > p = "."; > plen = strlen(p); > while (p[plen-1] == '/') > p[--plen] = '\0'; /* strip trailing '/' */ > ... > } In the first iteration, we have p == path. If PATH begins with "/:", we'll have p[0] == '/' and plen == 1, so the inner loop runs once, after which plen == 0. Then, to check the loop condition the program accesses p[plen-1], i.e., path[-1]. [0] https://marc.info/?l=openbsd-misc&m=145270213529011&w=2 Index: usr.bin/which/which.c === RCS file: /cvs/src/usr.bin/which/which.c,v retrieving revision 1.22 diff -u -p -r1.22 which.c --- usr.bin/which/which.c 29 Dec 2015 19:04:46 - 1.22 +++ usr.bin/which/which.c 14 Jan 2016 00:21:45 - @@ -124,7 +124,7 @@ findprog(char *prog, char *path, int pro p = "."; plen = strlen(p); - while (p[plen-1] == '/') + while (plen > 0 && p[plen-1] == '/') p[--plen] = '\0'; /* strip trailing '/' */ if (plen + 1 + proglen >= sizeof(filename)) {
[patch]: Small which(1) man page error
The man page says that which(1) works with unset PATH environment variable, as long as the argument is a pathname. However: $ unset PATH $ /usr/bin/which /usr/bin/which which: can't get $PATH from environment: Undefined error: 0 Index: usr.bin/which/which.1 === RCS file: /cvs/src/usr.bin/which/which.1,v retrieving revision 1.24 diff -u -p -r1.24 which.1 --- usr.bin/which/which.1 14 Aug 2013 06:32:30 - 1.24 +++ usr.bin/which/which.1 14 Jan 2016 00:21:45 - @@ -58,8 +58,7 @@ The following environment variables affe A colon-separated list of directories in which to find executables. If .Ev PATH -is not set, and the given name is not a fully qualified -or relative pathname, +is not set, .Nm will fail. .El
Re: gcc typo
Jan Schreiber wrote: > this looks like a typo in gcc. Committed. Thanks! > Index: gnu/gcc/gcc/config/mt/mt.c > === > RCS file: /cvs/src/gnu/gcc/gcc/config/mt/mt.c,v > retrieving revision 1.1.1.1 > diff -u -p -r1.1.1.1 mt.c > --- gnu/gcc/gcc/config/mt/mt.c15 Oct 2009 17:11:30 - 1.1.1.1 > +++ gnu/gcc/gcc/config/mt/mt.c12 Jan 2016 20:07:28 - > @@ -475,7 +475,7 @@ mt_print_operand (FILE * file, rtx x, in >break; > > default: > - fprintf(file, "Uknown code: %d", GET_CODE (x)); > + fprintf(file, "Unknown code: %d", GET_CODE (x)); >break; > } > >
[diff] IFQ has its own protection
Hello - IFQ has its own protection, so no need for splnet/splx. if_gif.c - use for (;;) to match the other drivers. Index: net/if_gif.c === RCS file: /cvs/src/sys/net/if_gif.c,v retrieving revision 1.83 diff -u -p -r1.83 if_gif.c --- net/if_gif.c5 Dec 2015 10:07:55 - 1.83 +++ net/if_gif.c14 Jan 2016 00:26:10 - @@ -164,13 +164,9 @@ gif_start(struct ifnet *ifp) { struct gif_softc *sc = (struct gif_softc*)ifp; struct mbuf *m; - int s; - while (1) { - s = splnet(); + for (;;) { IFQ_DEQUEUE(&ifp->if_snd, m); - splx(s); - if (m == NULL) break; Index: net/if_mpe.c === RCS file: /cvs/src/sys/net/if_mpe.c,v retrieving revision 1.52 diff -u -p -r1.52 if_mpe.c --- net/if_mpe.c5 Dec 2015 10:07:55 - 1.52 +++ net/if_mpe.c14 Jan 2016 00:26:10 - @@ -143,16 +143,12 @@ mpestart(struct ifnet *ifp0) { struct mbuf *m; struct sockaddr *sa = (struct sockaddr *)&mpedst; - int s; sa_family_t af; struct rtentry *rt; struct ifnet*ifp; for (;;) { - s = splnet(); IFQ_DEQUEUE(&ifp0->if_snd, m); - splx(s); - if (m == NULL) return; Index: net/if_pppx.c === RCS file: /cvs/src/sys/net/if_pppx.c,v retrieving revision 1.48 diff -u -p -r1.48 if_pppx.c --- net/if_pppx.c 5 Dec 2015 16:09:09 - 1.48 +++ net/if_pppx.c 14 Jan 2016 00:26:10 - @@ -995,15 +995,13 @@ pppx_if_start(struct ifnet *ifp) { struct pppx_if *pxi = (struct pppx_if *)ifp->if_softc; struct mbuf *m; - int proto, s; + int proto; if (!ISSET(ifp->if_flags, IFF_RUNNING)) return; for (;;) { - s = splnet(); IFQ_DEQUEUE(&ifp->if_snd, m); - splx(s); if (m == NULL) break; Index: net/if_vxlan.c === RCS file: /cvs/src/sys/net/if_vxlan.c,v retrieving revision 1.35 diff -u -p -r1.35 if_vxlan.c --- net/if_vxlan.c 5 Dec 2015 10:07:55 - 1.35 +++ net/if_vxlan.c 14 Jan 2016 00:26:10 - @@ -275,15 +275,12 @@ void vxlanstart(struct ifnet *ifp) { struct mbuf *m; - int s; for (;;) { - s = splnet(); IFQ_DEQUEUE(&ifp->if_snd, m); - splx(s); - if (m == NULL) return; + ifp->if_opackets++; #if NBPFILTER > 0
[less] start simplifying message buffer logic
message is a global static char[2048]. If I understand correctly (I've been playing with this for a while): * message is the user command result message displayed at the bottom (e.g. "Pattern not found (press RETURN)") * message is initialized to all NUL bytes because it's static * the global static mp points to message's terminating NUL I think we should try to drop mp. This would allow us to remove many of the goofy homebrewed appending functions and call strlcat et al. directly. They are currently just strlcat et al. clones that also update mp. Alternatives include: * storing message's length * just calling strlen when necessary The strlen calls are a performance price, but message has a small max size, is usually very small (almost all command messages are concise), and is only updated on user interaction. I thought I'd describe this to see if other people consider it an improvement. The below is a tiny first step, removing uses of mp to determine whether message is empty. Thoughts? ok? Index: prompt.c === RCS file: /cvs/src/usr.bin/less/prompt.c,v retrieving revision 1.20 diff -u -p -r1.20 prompt.c --- prompt.c13 Jan 2016 22:47:45 - 1.20 +++ prompt.c13 Jan 2016 22:58:16 - @@ -174,7 +174,7 @@ cond(char c, int where) switch (c) { case 'a': /* Anything in the message yet? */ - return (mp > message); + return (*message != '\0'); case 'b': /* Current byte offset known? */ return (curr_byte(where) != -1); case 'c': @@ -478,7 +478,7 @@ pr_expand(const char *proto, int maxwidt } } - if (mp == message) + if (*message == '\0') return (""); if (maxwidth > 0 && mp >= message + maxwidth) { /*
Re: Simplify less(1) off_t formatting
Looks good, ok nicm On Wed, Jan 13, 2016 at 05:42:56PM -0500, Michael McConville wrote: > Nicholas Marriott wrote: > > I like the idea, but I don't like calling them ap_off_t and offttoa, > > I'd just keep ap_pos and postoa and remove the linenum functions. > > Does this look good? > > > Index: less.h > === > RCS file: /cvs/src/usr.bin/less/less.h,v > retrieving revision 1.21 > diff -u -p -r1.21 less.h > --- less.h12 Jan 2016 17:48:04 - 1.21 > +++ less.h13 Jan 2016 22:40:49 - > @@ -206,5 +206,4 @@ struct textlist { > > /* Functions not included in funcs.h */ > void postoa(off_t, char *, size_t); > -void linenumtoa(off_t, char *, size_t); > void inttoa(int, char *, size_t); > Index: line.c > === > RCS file: /cvs/src/usr.bin/less/line.c,v > retrieving revision 1.16 > diff -u -p -r1.16 line.c > --- line.c12 Jan 2016 17:48:04 - 1.16 > +++ line.c13 Jan 2016 22:40:49 - > @@ -178,7 +178,7 @@ plinenum(off_t pos) > char buf[INT_STRLEN_BOUND(pos) + 2]; > int n; > > - linenumtoa(linenum, buf, sizeof (buf)); > + postoa(linenum, buf, sizeof(buf)); > n = strlen(buf); > if (n < MIN_LINENUM_WIDTH) > n = MIN_LINENUM_WIDTH; > Index: output.c > === > RCS file: /cvs/src/usr.bin/less/output.c,v > retrieving revision 1.14 > diff -u -p -r1.14 output.c > --- output.c 12 Jan 2016 17:48:04 - 1.14 > +++ output.c 13 Jan 2016 22:40:50 - > @@ -149,7 +149,6 @@ funcname(type num, char *buf, size_t len > } > > TYPE_TO_A_FUNC(postoa, off_t) > -TYPE_TO_A_FUNC(linenumtoa, off_t) > TYPE_TO_A_FUNC(inttoa, int) > > /* > @@ -173,7 +172,7 @@ iprint_linenum(off_t num) > { > char buf[INT_STRLEN_BOUND(num)]; > > - linenumtoa(num, buf, sizeof (buf)); > + postoa(num, buf, sizeof(buf)); > putstr(buf); > return (strlen(buf)); > } > Index: prompt.c > === > RCS file: /cvs/src/usr.bin/less/prompt.c,v > retrieving revision 1.19 > diff -u -p -r1.19 prompt.c > --- prompt.c 12 Jan 2016 23:01:23 - 1.19 > +++ prompt.c 13 Jan 2016 22:40:50 - > @@ -120,19 +120,7 @@ ap_pos(off_t pos) > { > char buf[INT_STRLEN_BOUND(pos) + 2]; > > - postoa(pos, buf, sizeof buf); > - ap_str(buf); > -} > - > -/* > - * Append a line number to the end of the message. > - */ > -static void > -ap_linenum(off_t linenum) > -{ > - char buf[INT_STRLEN_BOUND(linenum) + 2]; > - > - linenumtoa(linenum, buf, sizeof buf); > + postoa(pos, buf, sizeof(buf)); > ap_str(buf); > } > > @@ -255,7 +243,7 @@ protochar(int c, int where) > case 'd': /* Current page number */ > linenum = currline(where); > if (linenum > 0 && sc_height > 1) > - ap_linenum(PAGE_NUM(linenum)); > + ap_pos(PAGE_NUM(linenum)); > else > ap_quest(); > break; > @@ -266,13 +254,13 @@ protochar(int c, int where) > ap_quest(); > } else if (len == 0) { > /* An empty file has no pages. */ > - ap_linenum(0); > + ap_pos(0); > } else { > linenum = find_linenum(len - 1); > if (linenum <= 0) > ap_quest(); > else > - ap_linenum(PAGE_NUM(linenum)); > + ap_pos(PAGE_NUM(linenum)); > } > break; > case 'E': /* Editor name */ > @@ -293,7 +281,7 @@ protochar(int c, int where) > case 'l': /* Current line number */ > linenum = currline(where); > if (linenum != 0) > - ap_linenum(linenum); > + ap_pos(linenum); > else > ap_quest(); > break; > @@ -303,7 +291,7 @@ protochar(int c, int where) > (linenum = find_linenum(len)) <= 0) > ap_quest(); > else > - ap_linenum(linenum-1); > + ap_pos(linenum-1); > break; > case 'm': /* Number of files */ > n = ntags();
Re: Simplify less(1) off_t formatting
Nicholas Marriott wrote: > I like the idea, but I don't like calling them ap_off_t and offttoa, > I'd just keep ap_pos and postoa and remove the linenum functions. Does this look good? Index: less.h === RCS file: /cvs/src/usr.bin/less/less.h,v retrieving revision 1.21 diff -u -p -r1.21 less.h --- less.h 12 Jan 2016 17:48:04 - 1.21 +++ less.h 13 Jan 2016 22:40:49 - @@ -206,5 +206,4 @@ struct textlist { /* Functions not included in funcs.h */ void postoa(off_t, char *, size_t); -void linenumtoa(off_t, char *, size_t); void inttoa(int, char *, size_t); Index: line.c === RCS file: /cvs/src/usr.bin/less/line.c,v retrieving revision 1.16 diff -u -p -r1.16 line.c --- line.c 12 Jan 2016 17:48:04 - 1.16 +++ line.c 13 Jan 2016 22:40:49 - @@ -178,7 +178,7 @@ plinenum(off_t pos) char buf[INT_STRLEN_BOUND(pos) + 2]; int n; - linenumtoa(linenum, buf, sizeof (buf)); + postoa(linenum, buf, sizeof(buf)); n = strlen(buf); if (n < MIN_LINENUM_WIDTH) n = MIN_LINENUM_WIDTH; Index: output.c === RCS file: /cvs/src/usr.bin/less/output.c,v retrieving revision 1.14 diff -u -p -r1.14 output.c --- output.c12 Jan 2016 17:48:04 - 1.14 +++ output.c13 Jan 2016 22:40:50 - @@ -149,7 +149,6 @@ funcname(type num, char *buf, size_t len } TYPE_TO_A_FUNC(postoa, off_t) -TYPE_TO_A_FUNC(linenumtoa, off_t) TYPE_TO_A_FUNC(inttoa, int) /* @@ -173,7 +172,7 @@ iprint_linenum(off_t num) { char buf[INT_STRLEN_BOUND(num)]; - linenumtoa(num, buf, sizeof (buf)); + postoa(num, buf, sizeof(buf)); putstr(buf); return (strlen(buf)); } Index: prompt.c === RCS file: /cvs/src/usr.bin/less/prompt.c,v retrieving revision 1.19 diff -u -p -r1.19 prompt.c --- prompt.c12 Jan 2016 23:01:23 - 1.19 +++ prompt.c13 Jan 2016 22:40:50 - @@ -120,19 +120,7 @@ ap_pos(off_t pos) { char buf[INT_STRLEN_BOUND(pos) + 2]; - postoa(pos, buf, sizeof buf); - ap_str(buf); -} - -/* - * Append a line number to the end of the message. - */ -static void -ap_linenum(off_t linenum) -{ - char buf[INT_STRLEN_BOUND(linenum) + 2]; - - linenumtoa(linenum, buf, sizeof buf); + postoa(pos, buf, sizeof(buf)); ap_str(buf); } @@ -255,7 +243,7 @@ protochar(int c, int where) case 'd': /* Current page number */ linenum = currline(where); if (linenum > 0 && sc_height > 1) - ap_linenum(PAGE_NUM(linenum)); + ap_pos(PAGE_NUM(linenum)); else ap_quest(); break; @@ -266,13 +254,13 @@ protochar(int c, int where) ap_quest(); } else if (len == 0) { /* An empty file has no pages. */ - ap_linenum(0); + ap_pos(0); } else { linenum = find_linenum(len - 1); if (linenum <= 0) ap_quest(); else - ap_linenum(PAGE_NUM(linenum)); + ap_pos(PAGE_NUM(linenum)); } break; case 'E': /* Editor name */ @@ -293,7 +281,7 @@ protochar(int c, int where) case 'l': /* Current line number */ linenum = currline(where); if (linenum != 0) - ap_linenum(linenum); + ap_pos(linenum); else ap_quest(); break; @@ -303,7 +291,7 @@ protochar(int c, int where) (linenum = find_linenum(len)) <= 0) ap_quest(); else - ap_linenum(linenum-1); + ap_pos(linenum-1); break; case 'm': /* Number of files */ n = ntags();
[calendar] Addition of a United Kingdom holiday file
Hello there, Following on from a bit of discussion on & off misc@, below is an attempt at a United Kingdom calendar file, with major items already in calendar.holiday ommitted. e.g. New Year's Day, although it is an offical bank/public holiday. http://openbsd-archive.7691.n7.nabble.com/DIFF-New-Year-s-calendar-td286907.html The new file isn't super solid, but could be a resonable starting point. It would be difficult for an additional English language calendar file to be perfect due to a number of existing duplicate items, in multiple files, which I'm trying to tread quietly around numerous changes. Much of the formatting, grammar &c. is a matter of taste, while being similar to existing entries. There is an incorrect entry in calendar.holiday for an August bank holiday. The name was wrong & dates wrong for 2 countries. 2 other countries of the UK were missing it on a different date, and as it isn't of any international significance, I've corrected it in the new U.K. file. Some refs (watch out for multiple mistakes on Wikipedia): http://www.gov.scot/Topics/People/bank-holidays/ http://www.gov.uk/bank-holidays http://en.wikipedia.org/wiki/Public_holidays_in_the_United_Kingdom http://en.wikipedia.org/wiki/Bank_holiday http://en.wikipedia.org/wiki/Guy_Fawkes_Night http://en.wikipedia.org/wiki/Eleventh_Night Index: calendar.1 === RCS file: /cvs/src/usr.bin/calendar/calendar.1,v retrieving revision 1.40 diff -u -p -r1.40 calendar.1 --- calendar.1 7 Dec 2015 18:46:35 - 1.40 +++ calendar.1 13 Jan 2016 21:44:19 - @@ -237,6 +237,8 @@ Pagan holidays, celebrations and festiva Russian calendar. .It Pa calendar.space Cosmic history. +.It Pa calendar.united-kingdom +U.K. holidays, celebrations and festivals. .It Pa calendar.ushistory U.S. history. .It Pa calendar.usholiday Index: calendars/calendar.all === RCS file: /cvs/src/usr.bin/calendar/calendars/calendar.all,v retrieving revision 1.5 diff -u -p -r1.5 calendar.all --- calendars/calendar.all 15 Mar 2013 08:37:10 - 1.5 +++ calendars/calendar.all 13 Jan 2016 21:44:19 - @@ -17,5 +17,6 @@ #include #include #include +#include #endif /* !_calendar_all_ */ Index: calendars/calendar.holiday === RCS file: /cvs/src/usr.bin/calendar/calendars/calendar.holiday,v retrieving revision 1.33 diff -u -p -r1.33 calendar.holiday --- calendars/calendar.holiday 5 Jan 2016 08:28:02 - 1.33 +++ calendars/calendar.holiday 13 Jan 2016 21:44:20 - @@ -284,7 +284,6 @@ 08/03 Independence Day in Jamaica, Niger 08/03 Memorial Day of Archbishop Makarios in Cyprus 08/04 Freedom Day in Guyana -08/05* Bank Holiday in Scotland and Northern Ireland 08/06 Bank Holiday in Australia, British Columbia, Fiji, Iceland, Ireland, Ontario 08/06 Emancipation Day in Bahamas @@ -434,7 +433,7 @@ 11/30 Independence Day in Barbados, People's Democratic Yemen Republic 11/30 National Day in Benin 11/30 National Heroes Day in Philippines -11/30 St. Andrew's Day +11/30 Saint Andrew's Day (also a bank holiday in Scotland) 12/01 Independence Day in Central African Republic 12/01 World AIDS Day 12/01 National Day in Romania --- /dev/null Wed Jan 13 21:44:46 2016 +++ calendars/calendar.united-kingdom Wed Jan 13 21:42:48 2016 @@ -0,0 +1,40 @@ +/* + * United Kingdom holiday + * + * $OpenBSD$ + */ + +#ifndef _calendar_united-kingdom_ +#define _calendar_united-kingdom_ + +01/02 2nd January bank holiday in Scotland - another new year's holiday +01/25 Burns' Night in Scotland +02/14 Saint Valentine's Day +03/01 Saint David's Day in Wales +03/17 Saint Patrick's Day (also a bank holiday across Ireland) +03/20* Vernal Equinox +03/SunLast Daylight Saving Time begins; clocks move forward (last Sunday of March) +04/01 April Fool's Day +04/23 Saint George's Day in England +Easter-21 Mothering Sunday (Sunday 3 weeks before Easter Sunday) +Easter-2 Good Friday (bank holiday) +Easter+1 Easter Monday (bank holiday - except Scotland) +05/MonFirstEarly May Bank Holiday +05/MonThird* Victoria Day in Scotland (Monday on or immediately before 24th May) +05/MonLast Spring Bank Holiday +06/SunThirdFather's Day (3rd Sunday of June) +06/21* Summer Solstice +07/11 Eleventh Night in Northern Ireland +07/12 Battle of the Boyne/Orangemen's Day/The Twelfth - a bank holiday in Northern Ireland +08/MonFirstSummer Bank Holiday in Scotland +08/MonLast Summer Bank Holiday in England, Wales and Northern Ireland +09/22* Autumnal Equinox +10/SunLast Daylight Saving Time ends; clocks move back (last Sunday in October) +10/31 Halloween +11/05 Guy Fawkes' Night +11/11 Remembrance Day +11/SunSecond Remembrance Sunday +12/21* Winter Solstice +12/31 Hogmanay + +#endif /* !_calendar_united-kingdom_ */
tty uiomove() conversion
Below the conversion from uiomovei() to uiomove() for kern/tty.c and kern/tty_pty.c. 'cc' consistently contains small, non-negative integer values, so leaving the type as int should be ok. It could as well be changed to size_t, but I don't see a benefit in doing so for that particular case, except for a lot of unnecessary code churn. Index: kern/tty.c === RCS file: /cvs/src/sys/kern/tty.c,v retrieving revision 1.127 diff -u -p -u -r1.127 tty.c --- kern/tty.c 5 Dec 2015 10:11:53 - 1.127 +++ kern/tty.c 13 Jan 2016 21:22:22 - @@ -1782,7 +1782,7 @@ loop: if (cc == 0) { cc = MIN(uio->uio_resid, OBUFSIZ); cp = obuf; - error = uiomovei(cp, cc, uio); + error = uiomove(cp, cc, uio); if (error) { cc = 0; break; Index: kern/tty_pty.c === RCS file: /cvs/src/sys/kern/tty_pty.c,v retrieving revision 1.74 diff -u -p -u -r1.74 tty_pty.c --- kern/tty_pty.c 5 Dec 2015 10:11:53 - 1.74 +++ kern/tty_pty.c 13 Jan 2016 21:22:22 - @@ -461,7 +461,7 @@ ptcread(dev_t dev, struct uio *uio, int if (pti->pt_send & TIOCPKT_IOCTL) { cc = MIN(uio->uio_resid, sizeof(tp->t_termios)); - error = uiomovei(&tp->t_termios, cc, uio); + error = uiomove(&tp->t_termios, cc, uio); if (error) return (error); } @@ -496,7 +496,7 @@ ptcread(dev_t dev, struct uio *uio, int bufcc = cc; if (cc <= 0) break; - error = uiomovei(buf, cc, uio); + error = uiomove(buf, cc, uio); } ttwakeupwr(tp); if (bufcc) @@ -529,7 +529,7 @@ again: if (cc > bufcc) bufcc = cc; cp = buf; - error = uiomovei(cp, cc, uio); + error = uiomove(cp, cc, uio); if (error) goto done; /* check again for safety */ @@ -553,7 +553,7 @@ again: if (cc > bufcc) bufcc = cc; cp = buf; - error = uiomovei(cp, cc, uio); + error = uiomove(cp, cc, uio); if (error) goto done; /* check again for safety */ cheers, natano
Re: [PATCH] Missing break in audio.c
On Wed, Jan 13, 2016 at 06:03:17PM +0200, Ville Valkonen wrote: > looks like there's a missing break in audio.c, since error gets assigned > twice and not read in between. You're right, but this has already been fixed in -current a few days ago: http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/sys/dev/audio.c.diff?r1=1.140&r2=1.141 Please make sure your tree is up to date > > --- sys/dev/audio.c.oldWed Jan 13 17:55:32 2016 > +++ sys/dev/audio.cWed Jan 13 17:55:48 2016 > @@ -1704,6 +1704,7 @@ audioclose(dev_t dev, int flags, int ifmt, struct proc > case AUDIO_DEV_MIXER: > case AUDIO_DEV_AUDIOCTL: > error = 0; > +break; > default: > error = ENXIO; > } > > -- > Kind regards, > Ville Valkonen
5.8 ifconfig vlan test
Hi, When creating, changing and destroying vlan interfaces multiple times, root can crash the OpenBSD 5.8 kernel with ifconfig. The code in -current has been implemented differently, so this fix only applies to 5.8. As I cannot test it with -current machines, could someone with OpenBSD 5.8 and some funky vlan configuration run this diff? When I get enough positive reports, I will commit to 5.8-stable. 5.7 is not affected. bluhm Index: net/if_vlan.c === RCS file: /mount/cvsdev/cvs/openbsd/src/sys/net/if_vlan.c,v retrieving revision 1.135 diff -u -p -r1.135 if_vlan.c --- net/if_vlan.c 20 Jul 2015 22:16:41 - 1.135 +++ net/if_vlan.c 11 Jan 2016 17:34:19 - @@ -347,6 +347,7 @@ vlan_input(struct ifnet *ifp, struct mbu int vlan_config(struct ifvlan *ifv, struct ifnet *p, u_int16_t tag) { + struct ifih *vlan_ifih; struct sockaddr_dl *sdl1, *sdl2; struct vlan_taghash *tagh; u_intflags; @@ -358,15 +359,17 @@ vlan_config(struct ifvlan *ifv, struct i return (0); /* Can we share an ifih between multiple vlan(4) instances? */ - ifv->ifv_ifih = SLIST_FIRST(&p->if_inputs); - if (ifv->ifv_ifih->ifih_input != vlan_input) { - ifv->ifv_ifih = malloc(sizeof(*ifv->ifv_ifih), M_DEVBUF, + vlan_ifih = SLIST_FIRST(&p->if_inputs); + if (vlan_ifih->ifih_input != vlan_input) { + vlan_ifih = malloc(sizeof(*vlan_ifih), M_DEVBUF, M_NOWAIT); - if (ifv->ifv_ifih == NULL) + if (vlan_ifih == NULL) return (ENOMEM); - ifv->ifv_ifih->ifih_input = vlan_input; - ifv->ifv_ifih->ifih_refcnt = 0; + vlan_ifih->ifih_input = vlan_input; + vlan_ifih->ifih_refcnt = 0; } + /* Do no free our reference during vlan_unconfig() */ + ++vlan_ifih->ifih_refcnt; /* Remember existing interface flags and reset the interface */ flags = ifv->ifv_flags; @@ -437,8 +440,9 @@ vlan_config(struct ifvlan *ifv, struct i s = splnet(); /* Change input handler of the physical interface. */ - if (++ifv->ifv_ifih->ifih_refcnt == 1) - SLIST_INSERT_HEAD(&p->if_inputs, ifv->ifv_ifih, ifih_next); + ifv->ifv_ifih = vlan_ifih; + if (vlan_ifih->ifih_refcnt == 1) + SLIST_INSERT_HEAD(&p->if_inputs, vlan_ifih, ifih_next); LIST_INSERT_HEAD(&tagh[TAG_HASH(tag)], ifv, ifv_list); splx(s);
ppp_tty uiomove() conversion
Below the uiomove() conversion for net/ppp_tty.c. M_TRAILINGSPACE() returns int, but the result can't be negative, so using u_int for the return value should be fine. Index: net/ppp_tty.c === RCS file: /cvs/src/sys/net/ppp_tty.c,v retrieving revision 1.41 diff -u -p -u -r1.41 ppp_tty.c --- net/ppp_tty.c 21 Dec 2015 21:49:02 - 1.41 +++ net/ppp_tty.c 13 Jan 2016 19:44:53 - @@ -321,7 +321,7 @@ pppread(struct tty *tp, struct uio *uio, splx(s); for (m = m0; m && uio->uio_resid; m = m->m_next) - if ((error = uiomovei(mtod(m, u_char *), m->m_len, uio)) != 0) + if ((error = uiomove(mtod(m, u_char *), m->m_len, uio)) != 0) break; m_freem(m0); return (error); @@ -336,7 +336,8 @@ pppwrite(struct tty *tp, struct uio *uio struct ppp_softc *sc = (struct ppp_softc *)tp->t_sc; struct mbuf *m, *m0, **mp; struct sockaddr dst; -int len, error; +u_int len; +int error; if ((tp->t_state & TS_CARR_ON) == 0 && (tp->t_cflag & CLOCAL) == 0) return 0; /* wrote 0 bytes */ @@ -361,7 +362,7 @@ pppwrite(struct tty *tp, struct uio *uio len = M_TRAILINGSPACE(m); if (len > uio->uio_resid) len = uio->uio_resid; - if ((error = uiomovei(mtod(m, u_char *), len, uio)) != 0) { + if ((error = uiomove(mtod(m, u_char *), len, uio)) != 0) { m_freem(m0); return (error); } cheers, natano
spec_vnops.c uiomove() conversion
Below the conversion to uiomove() for kern/spec_vnops.c. This diff prevents truncation of uio_resid when passed to min(). Index: kern/spec_vnops.c === RCS file: /cvs/src/sys/kern/spec_vnops.c,v retrieving revision 1.84 diff -u -p -u -r1.84 spec_vnops.c --- kern/spec_vnops.c 5 Dec 2015 10:11:53 - 1.84 +++ kern/spec_vnops.c 13 Jan 2016 19:12:40 - @@ -202,7 +202,8 @@ spec_read(void *v) daddr_t bn, nextbn, bscale; int bsize; struct partinfo dpart; - int n, on, majordev; + size_t n; + int on, majordev; int (*ioctl)(dev_t, u_long, caddr_t, int, struct proc *); int error = 0; @@ -243,7 +244,7 @@ spec_read(void *v) do { bn = btodb(uio->uio_offset) & ~(bscale - 1); on = uio->uio_offset % bsize; - n = min((bsize - on), uio->uio_resid); + n = ulmin((bsize - on), uio->uio_resid); if (vp->v_lastr + bscale == bn) { nextbn = bn + bscale; error = breadn(vp, bn, bsize, &nextbn, &bsize, @@ -251,12 +252,12 @@ spec_read(void *v) } else error = bread(vp, bn, bsize, &bp); vp->v_lastr = bn; - n = min(n, bsize - bp->b_resid); + n = ulmin(n, bsize - bp->b_resid); if (error) { brelse(bp); return (error); } - error = uiomovei((char *)bp->b_data + on, n, uio); + error = uiomove((char *)bp->b_data + on, n, uio); brelse(bp); } while (error == 0 && uio->uio_resid > 0 && n != 0); return (error); @@ -290,7 +291,8 @@ spec_write(void *v) daddr_t bn, bscale; int bsize; struct partinfo dpart; - int n, on, majordev; + size_t n; + int on, majordev; int (*ioctl)(dev_t, u_long, caddr_t, int, struct proc *); int error = 0; @@ -331,14 +333,14 @@ spec_write(void *v) do { bn = btodb(uio->uio_offset) & ~(bscale - 1); on = uio->uio_offset % bsize; - n = min((bsize - on), uio->uio_resid); + n = ulmin((bsize - on), uio->uio_resid); error = bread(vp, bn, bsize, &bp); - n = min(n, bsize - bp->b_resid); + n = ulmin(n, bsize - bp->b_resid); if (error) { brelse(bp); return (error); } - error = uiomovei((char *)bp->b_data + on, n, uio); + error = uiomove((char *)bp->b_data + on, n, uio); if (n + on == bsize) bawrite(bp); else cheers, natano
Re: patch for security.html
committed, thanks On Wed, Jan 13, 2016 at 12:35:34PM +, Sevan Janiyan wrote: > Hi, > Attached patch removes references to vendors and generalises by > referring to "most vendors" (Sun & SGI no longer exist as the company > they once were and this saves from maintaining a list). > Links to innovations.html when referring to other new technologies. > > src is now over 850MB in size (better to say 875MB?) > > Instead of mentioning that i386 snapshots are built weekly, mention that > amd64 snapshots are made available daily. > > > Question regarding the PGP key linked on the page, time for a new key > which is a larger key size than 1024 bit? > > > > Sevan > Index: security.html > === > RCS file: /cvs/www/security.html,v > retrieving revision 1.423 > diff -u -p -r1.423 security.html > --- security.html 19 Oct 2015 12:30:56 - 1.423 > +++ security.html 13 Jan 2016 12:26:15 - > @@ -69,8 +69,8 @@ For security advisories for specific rel > OpenBSD believes in strong security. Our aspiration is to be NUMBER > ONE in the industry for security (if we are not already there). Our > open software development model permits us to take a more > -uncompromising view towards increased security than Sun, SGI, IBM, HP, > -or other vendors are able to. We can make changes the vendors would > +uncompromising view towards increased security than most vendors are > +able to. We can make changes the vendors would > not make. Also, since OpenBSD is exported with > cryptography, we are able to take cryptographic approaches towards > fixing security problems. > @@ -159,7 +159,7 @@ written somewhere, but perhaps not taken >Chroot jailing >New uids >ProPolice > - ... and others > + ... and others > > > > @@ -258,11 +258,11 @@ things: > carefully). Users can make the assumption that the current > source tree always has stronger security than the previous release. > However, building your own system from source code is not trivial; > - it is nearly 850MB of source code, and problems do occur as we > + it is over 850MB of source code, and problems do occur as we > transition between major releases. > Install a binary snapshot for your > architecture, which are made available fairly often. For > - instance, an i386 snapshot is typically made available weekly. > + instance, an amd64 snapshot is typically made available daily. > > >
Re: [PATCH] unsignedness comparison in brconfig.c
> no need to check if unsigned value is smaller than zero. Please see the > attached patch. > > Gmail likely mangles the inlined patch but here it goes: > --- brconfig.c.oldWed Jan 13 16:35:39 2016 > +++ brconfig.cWed Jan 13 16:36:26 2016 > @@ -563,7 +563,7 @@ bridge_ifcost(const char *ifname, const char *val) > errno = 0; > v = strtoul(val, &endptr, 0); > if (val[0] == '\0' || endptr[0] != '\0' || > -v < 0 || v > 0xUL || > +v > 0xUL || > (errno == ERANGE && v == ULONG_MAX)) > errx(1, "invalid arg for ifcost: %s", val); It would be better to (very carefully) refactor almost all of those to strtonum. After such a change operands must be in decimal. Octal / hex become unacceptable. From a user perspective that is the right thing to do, meaning "base == 0" can be looked upon as an error in the original code. Overly flexible code is not smart code. (Where's my binary support??? Where is my ability to pass in a base64 encoded number??)
Re: Increasing ppp/tty buffer sizes
> On Wed, 13 Jan 2016, Theo de Raadt wrote: > > - tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED; > > + tp->t_ispeed = tp->t_ospeed = 100; > > > > I don't think that is the right thing to do, without some testing. > > That is directly visible in the program running on the pty. Some > > programs make decisions based upon baud rate, but what worries me here > > is this doesn't match one of the Bx standard speeds. Some legacy > > ports programs may still expect that speeds need to match those. > > > > Can pty memory allocation behaviour be kept independent of this? > > > > Certainly I wouldn't mind if that is set to B115200. > > > > The memory allocation is independent of this, but ttsetwater() looks at > the t_ospeed for calculating the lo/hi watermarks. But with the current > implementation and the buffer sizes from the patch, t_ospeed = 100 and > t_ospeed = B115200 give the same watermarks. So B115200 is just as good. Good enough for me.
[PATCH] Missing break in audio.c
Hello, looks like there's a missing break in audio.c, since error gets assigned twice and not read in between. --- sys/dev/audio.c.oldWed Jan 13 17:55:32 2016 +++ sys/dev/audio.cWed Jan 13 17:55:48 2016 @@ -1704,6 +1704,7 @@ audioclose(dev_t dev, int flags, int ifmt, struct proc case AUDIO_DEV_MIXER: case AUDIO_DEV_AUDIOCTL: error = 0; +break; default: error = ENXIO; } -- Kind regards, Ville Valkonen --- sys/dev/audio.c.old Wed Jan 13 17:55:32 2016 +++ sys/dev/audio.c Wed Jan 13 17:55:48 2016 @@ -1704,6 +1704,7 @@ audioclose(dev_t dev, int flags, int ifmt, struct proc case AUDIO_DEV_MIXER: case AUDIO_DEV_AUDIOCTL: error = 0; + break; default: error = ENXIO; }
Re: [PATCH] octeon.html
committed, thanks!
[PATCH] unsignedness comparison in brconfig.c
Hello, no need to check if unsigned value is smaller than zero. Please see the attached patch. Gmail likely mangles the inlined patch but here it goes: --- brconfig.c.oldWed Jan 13 16:35:39 2016 +++ brconfig.cWed Jan 13 16:36:26 2016 @@ -563,7 +563,7 @@ bridge_ifcost(const char *ifname, const char *val) errno = 0; v = strtoul(val, &endptr, 0); if (val[0] == '\0' || endptr[0] != '\0' || -v < 0 || v > 0xUL || +v > 0xUL || (errno == ERANGE && v == ULONG_MAX)) errx(1, "invalid arg for ifcost: %s", val); -- Regards, Ville Valkonen --- brconfig.c.old Wed Jan 13 16:35:39 2016 +++ brconfig.c Wed Jan 13 16:36:26 2016 @@ -563,7 +563,7 @@ bridge_ifcost(const char *ifname, const char *val) errno = 0; v = strtoul(val, &endptr, 0); if (val[0] == '\0' || endptr[0] != '\0' || - v < 0 || v > 0xUL || + v > 0xUL || (errno == ERANGE && v == ULONG_MAX)) errx(1, "invalid arg for ifcost: %s", val);
Re: Increasing ppp/tty buffer sizes
On Wed, 13 Jan 2016, Theo de Raadt wrote: > - tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED; > + tp->t_ispeed = tp->t_ospeed = 100; > > I don't think that is the right thing to do, without some testing. > That is directly visible in the program running on the pty. Some > programs make decisions based upon baud rate, but what worries me here > is this doesn't match one of the Bx standard speeds. Some legacy > ports programs may still expect that speeds need to match those. > > Can pty memory allocation behaviour be kept independent of this? > > Certainly I wouldn't mind if that is set to B115200. > The memory allocation is independent of this, but ttsetwater() looks at the t_ospeed for calculating the lo/hi watermarks. But with the current implementation and the buffer sizes from the patch, t_ospeed = 100 and t_ospeed = B115200 give the same watermarks. So B115200 is just as good.
Re: Increasing ppp/tty buffer sizes
- tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED; + tp->t_ispeed = tp->t_ospeed = 100; I don't think that is the right thing to do, without some testing. That is directly visible in the program running on the pty. Some programs make decisions based upon baud rate, but what worries me here is this doesn't match one of the Bx standard speeds. Some legacy ports programs may still expect that speeds need to match those. Can pty memory allocation behaviour be kept independent of this? Certainly I wouldn't mind if that is set to B115200.
[PATCH] octeon.html
Hi tech@, Small diff to fix the link to the Portwell CAM-0100. Index: octeon.html === RCS file: /cvs/www/octeon.html,v retrieving revision 1.26 diff -u -p -u -p -r1.26 octeon.html --- octeon.html 17 Dec 2015 11:51:26 - 1.26 +++ octeon.html 13 Jan 2016 14:09:18 - @@ -61,7 +61,7 @@ local disk on machines lacking a CF slot OpenBSD/octeon supports the following machines: -http://www.portwell.com/products/detail.asp?CUSTCHAR1=CAM-0100";> +http://www.portwell.com/products/detail.php?CUSTCHAR1=CAM-0100";> Portwell CAM-0100 D-Link https://web.archive.org/web/20140803060102/http://www.dlink.com/us/en/business-solutions/security/services-routers/dsr-500-the-d-link-services-router";> DSR-500,
Increasing ppp/tty buffer sizes
Hi, the buffer sizes allocated in the tty layer are too small for todays use cases like l2tp and virtio-console. Also, the watermarks used by ppp are way to small and do not scale with the line speed. This patch - makes 115200 the default speed for buffer sizing in ttymalloc(). A lot of devices call ttymalloc(0) so this affects quite a few of them. - increases the buffer size for 9600 < baud <= 115200 from 1k to 4k - makes ppp use the lo/hi watermarks from the tty layer which are adjusted according to speed + buffer size. The previous fixed values of 100 and 400 were way too small - make pty call ttymalloc with baud == 100, which is the common value used in the tree for "fast". A slightly different variant of these changes were suggested and tested by Sergey Ryazanov. They result in significant speed-up when sending data with l2tp. I have also seen similar speed-up with the viocon driver. I am looking for OKs, comments, additional testers (especially normal ppp (not l2tp)). Cheers, Stefan diff --git sys/kern/tty.c sys/kern/tty.c index b276061..c9230be 100644 --- sys/kern/tty.c +++ sys/kern/tty.c @@ -2330,8 +2330,13 @@ ttymalloc(int baud) tp = malloc(sizeof(struct tty), M_TTYS, M_WAITOK|M_ZERO); - if (baud <= 115200) + if (baud == 0) + baud = 115200; + + if (baud <= 9600) tp->t_qlen = 1024; + else if (baud <= 115200) + tp->t_qlen = 4096; else tp->t_qlen = 8192; clalloc(&tp->t_rawq, tp->t_qlen, 1); diff --git sys/kern/tty_pty.c sys/kern/tty_pty.c index 40b2db2..de009b8 100644 --- sys/kern/tty_pty.c +++ sys/kern/tty_pty.c @@ -193,7 +193,7 @@ check_pty(int minor) if (!pt_softc[minor]) { pti = malloc(sizeof(struct pt_softc), M_DEVBUF, M_WAITOK|M_ZERO); - pti->pt_tty = ttymalloc(0); + pti->pt_tty = ttymalloc(100); ptydevname(minor, pti); pt_softc[minor] = pti; } @@ -235,7 +235,7 @@ ptsopen(dev_t dev, int flag, int devtype, struct proc *p) pti = pt_softc[minor(dev)]; if (!pti->pt_tty) { - tp = pti->pt_tty = ttymalloc(0); + tp = pti->pt_tty = ttymalloc(100); } else tp = pti->pt_tty; if ((tp->t_state & TS_ISOPEN) == 0) { @@ -245,7 +245,7 @@ ptsopen(dev_t dev, int flag, int devtype, struct proc *p) tp->t_oflag = TTYDEF_OFLAG; tp->t_lflag = TTYDEF_LFLAG; tp->t_cflag = TTYDEF_CFLAG; - tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED; + tp->t_ispeed = tp->t_ospeed = 100; ttsetwater(tp); /* would be done in xxparam() */ } else if (tp->t_state&TS_XCLUDE && suser(p, 0) != 0) return (EBUSY); @@ -412,7 +412,7 @@ ptcopen(dev_t dev, int flag, int devtype, struct proc *p) pti = pt_softc[minor(dev)]; if (!pti->pt_tty) { - tp = pti->pt_tty = ttymalloc(0); + tp = pti->pt_tty = ttymalloc(100); } else tp = pti->pt_tty; if (tp->t_oproc) diff --git sys/net/ppp_tty.c sys/net/ppp_tty.c index 186d4c7..94d9d4e 100644 --- sys/net/ppp_tty.c +++ sys/net/ppp_tty.c @@ -155,9 +155,6 @@ struct pool ppp_pkts; /* This is a NetBSD-1.0 or later kernel. */ #define CCOUNT(q) ((q)->c_cc) -#define PPP_LOWAT 100 /* Process more output when < LOWAT on queue */ -#definePPP_HIWAT 400 /* Don't start a new packet if HIWAT on queue */ - /* * Line specific open routine for async tty devices. * Attach the given tty to the first available ppp unit. @@ -499,7 +496,7 @@ pppasyncstart(struct ppp_softc *sc) int s; idle = 0; -while (CCOUNT(&tp->t_outq) < PPP_HIWAT) { +while (CCOUNT(&tp->t_outq) < tp->t_hiwat) { /* * See if we have an existing packet partly sent. * If not, get a new packet and start sending it. @@ -706,7 +703,7 @@ pppstart_internal(struct tty *tp, int force) * or been disconnected from the ppp unit, then tell if_ppp.c that * we need more output. */ -if ((CCOUNT(&tp->t_outq) < PPP_LOWAT || force) +if ((CCOUNT(&tp->t_outq) < tp->t_lowat || force) && !((tp->t_state & TS_CARR_ON) == 0 && (tp->t_cflag & CLOCAL) == 0) && sc != NULL && tp == (struct tty *) sc->sc_devp) { ppp_restart(sc);
patch for security.html
Hi, Attached patch removes references to vendors and generalises by referring to "most vendors" (Sun & SGI no longer exist as the company they once were and this saves from maintaining a list). Links to innovations.html when referring to other new technologies. src is now over 850MB in size (better to say 875MB?) Instead of mentioning that i386 snapshots are built weekly, mention that amd64 snapshots are made available daily. Question regarding the PGP key linked on the page, time for a new key which is a larger key size than 1024 bit? Sevan Index: security.html === RCS file: /cvs/www/security.html,v retrieving revision 1.423 diff -u -p -r1.423 security.html --- security.html 19 Oct 2015 12:30:56 - 1.423 +++ security.html 13 Jan 2016 12:26:15 - @@ -69,8 +69,8 @@ For security advisories for specific rel OpenBSD believes in strong security. Our aspiration is to be NUMBER ONE in the industry for security (if we are not already there). Our open software development model permits us to take a more -uncompromising view towards increased security than Sun, SGI, IBM, HP, -or other vendors are able to. We can make changes the vendors would +uncompromising view towards increased security than most vendors are +able to. We can make changes the vendors would not make. Also, since OpenBSD is exported with cryptography, we are able to take cryptographic approaches towards fixing security problems. @@ -159,7 +159,7 @@ written somewhere, but perhaps not taken Chroot jailing New uids ProPolice - ... and others + ... and others @@ -258,11 +258,11 @@ things: carefully). Users can make the assumption that the current source tree always has stronger security than the previous release. However, building your own system from source code is not trivial; - it is nearly 850MB of source code, and problems do occur as we + it is over 850MB of source code, and problems do occur as we transition between major releases. Install a binary snapshot for your architecture, which are made available fairly often. For - instance, an i386 snapshot is typically made available weekly. + instance, an amd64 snapshot is typically made available daily.
Re: ntpd.conf and Google
On 01/13/2016 06:10 AM, Theo de Raadt wrote: $ fgrep constraint /etc/ntpd.conf constraints from "https://www.google.com"; $ www.google.com and other Google services are not accessible from countries like China or Vietnam. It's easy enough for people to change their ntpd.conf if necessary but how about using a default value that is more likely to work for everyone? Something like https://www.un.org/ for example. That looks like a centralized service operated on a single provider network without global load balancing "features", the DNS TTL alone hints this would be unsuitable. Probably not built to the same scale, does not feel right to me. There are are a lot of variables involved in making a selection, and the result is certainly imperfect. I get where you are coming from, but you can probably see why we currently choose what we do. What about using https://www.akamai.com? smime.p7s Description: S/MIME Cryptographic Signature
patch: udp "len < 0" check in dhcrelay
dhcpd, dhclient and dhcrelay have not-quite-in-sync versions of packet.c; the one in dhcrelay is missing this check present in the others. OK to add it? Index: packet.c === RCS file: /cvs/src/usr.sbin/dhcrelay/packet.c,v retrieving revision 1.5 diff -u -p -r1.5 packet.c --- packet.c25 Oct 2014 03:23:49 - 1.5 +++ packet.c13 Jan 2016 10:52:18 - @@ -223,7 +223,7 @@ decode_udp_ip_header(struct interface_in data = buf + bufix + ip_len + sizeof(*udp); len = ntohs(udp->uh_ulen) - sizeof(*udp); udp_packets_length_checked++; - if (len + data > buf + bufix + buflen) { + if ((len < 0) || (len + data > buf + bufix + buflen)) { udp_packets_length_overflow++; if (udp_packets_length_checked > 4 && udp_packets_length_overflow != 0 &&
Re: Simplify less(1) off_t formatting
I like the idea, but I don't like calling them ap_off_t and offttoa, I'd just keep ap_pos and postoa and remove the linenum functions. On Tue, Jan 12, 2016 at 11:50:51PM -0500, Michael McConville wrote: > I'm working on bigger simplifications for less's string formatting, but > this is a good start. We've removed the off_t aliases for linenums and > positions, so we now have two identical sets of off_t formatting and > appending functions. The below diff unifies them. > > As you can see, there is more cleanup to be done. > > Thoughts? > > > Index: less.h > === > RCS file: /cvs/src/usr.bin/less/less.h,v > retrieving revision 1.21 > diff -u -p -r1.21 less.h > --- less.h12 Jan 2016 17:48:04 - 1.21 > +++ less.h13 Jan 2016 04:43:15 - > @@ -205,6 +205,5 @@ struct textlist { > #include "funcs.h" > > /* Functions not included in funcs.h */ > -void postoa(off_t, char *, size_t); > -void linenumtoa(off_t, char *, size_t); > +void offttoa(off_t, char *, size_t); > void inttoa(int, char *, size_t); > Index: line.c > === > RCS file: /cvs/src/usr.bin/less/line.c,v > retrieving revision 1.16 > diff -u -p -r1.16 line.c > --- line.c12 Jan 2016 17:48:04 - 1.16 > +++ line.c13 Jan 2016 04:43:15 - > @@ -178,7 +178,7 @@ plinenum(off_t pos) > char buf[INT_STRLEN_BOUND(pos) + 2]; > int n; > > - linenumtoa(linenum, buf, sizeof (buf)); > + offttoa(linenum, buf, sizeof(buf)); > n = strlen(buf); > if (n < MIN_LINENUM_WIDTH) > n = MIN_LINENUM_WIDTH; > Index: output.c > === > RCS file: /cvs/src/usr.bin/less/output.c,v > retrieving revision 1.14 > diff -u -p -r1.14 output.c > --- output.c 12 Jan 2016 17:48:04 - 1.14 > +++ output.c 13 Jan 2016 04:43:15 - > @@ -148,8 +148,7 @@ funcname(type num, char *buf, size_t len > (void) strlcpy(buf, s, len);\ > } > > -TYPE_TO_A_FUNC(postoa, off_t) > -TYPE_TO_A_FUNC(linenumtoa, off_t) > +TYPE_TO_A_FUNC(offttoa, off_t) > TYPE_TO_A_FUNC(inttoa, int) > > /* > @@ -173,7 +172,7 @@ iprint_linenum(off_t num) > { > char buf[INT_STRLEN_BOUND(num)]; > > - linenumtoa(num, buf, sizeof (buf)); > + offttoa(num, buf, sizeof(buf)); > putstr(buf); > return (strlen(buf)); > } > Index: prompt.c > === > RCS file: /cvs/src/usr.bin/less/prompt.c,v > retrieving revision 1.19 > diff -u -p -r1.19 prompt.c > --- prompt.c 12 Jan 2016 23:01:23 - 1.19 > +++ prompt.c 13 Jan 2016 04:43:15 - > @@ -116,23 +116,11 @@ ap_char(char c) > * Append a off_t (as a decimal integer) to the end of the message. > */ > static void > -ap_pos(off_t pos) > +ap_off_t(off_t pos) > { > char buf[INT_STRLEN_BOUND(pos) + 2]; > > - postoa(pos, buf, sizeof buf); > - ap_str(buf); > -} > - > -/* > - * Append a line number to the end of the message. > - */ > -static void > -ap_linenum(off_t linenum) > -{ > - char buf[INT_STRLEN_BOUND(linenum) + 2]; > - > - linenumtoa(linenum, buf, sizeof buf); > + offttoa(pos, buf, sizeof(buf)); > ap_str(buf); > } > > @@ -245,7 +233,7 @@ protochar(int c, int where) > case 'b': /* Current byte offset */ > pos = curr_byte(where); > if (pos != -1) > - ap_pos(pos); > + ap_off_t(pos); > else > ap_quest(); > break; > @@ -255,7 +243,7 @@ protochar(int c, int where) > case 'd': /* Current page number */ > linenum = currline(where); > if (linenum > 0 && sc_height > 1) > - ap_linenum(PAGE_NUM(linenum)); > + ap_off_t(PAGE_NUM(linenum)); > else > ap_quest(); > break; > @@ -266,13 +254,13 @@ protochar(int c, int where) > ap_quest(); > } else if (len == 0) { > /* An empty file has no pages. */ > - ap_linenum(0); > + ap_off_t(0); > } else { > linenum = find_linenum(len - 1); > if (linenum <= 0) > ap_quest(); > else > - ap_linenum(PAGE_NUM(linenum)); > + ap_off_t(PAGE_NUM(linenum)); > } > break; > case 'E': /* Editor name */ > @@ -293,7 +281,7 @@ protochar(int c, int where) > case 'l': /* Current line number */ > linenum = currline(where); > if (linenum != 0) > - ap_linenum(linenum); > +