freebsd-skq/lib
bde 0184c7ba03 Obtained from: 1.1.5
getcwd() has two off-by-one bugs in FreeBSD-2.0:

1. getcwd(buf, size) fails when the size is just large enough.
2. getcwd(buf + 1, 1) incorrectly succeeds when the current directory
   is "/".  buf[0] and buf[2] are clobbered.

(I modified Bruce's original patch to return the proper error code
[ERANGE] in the case of #2, but otherwise... -DG)

This program demonstrates the bug:

---
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>

int main(void)
{
    char buf[5];
    int errors;

    errors = 0;
    if (chdir("/tmp") != 0) {
        perror("chdir");
        abort();
    }
    if (getcwd(buf, 5) == NULL) {
        perror("oops, getcwd failed for buffer size = size required");
        ++errors;
    }
    if (chdir("/") != 0) {
        perror("chdir");
        abort();
    }
    buf[0] = 0;
    buf[2] = 1;
    if (getcwd(buf + 1, 1) != NULL) {
        fprintf(stderr,
                "oops, getcwd succeeded for buffer size = one too small\n");
        ++errors;
    }
    if (buf[0] != 0) {
        fprintf(stderr,
                "oops, getcwd scribbled on memory before start of buffer\n");
        ++errors;
    }
    if (buf[2] != 1) {
        fprintf(stderr,
                "oops, getcwd scribbled on memory after end of buffer\n");
        ++errors;
    }
    exit(errors == 0 ? 0 : 1);
}
1994-12-12 01:29:13 +00:00
..
csu/i386 Call reduced (8-bit only) startup_setlocale() 1994-09-24 16:01:30 +00:00
libc Obtained from: 1.1.5 1994-12-12 01:29:13 +00:00
libcompat Add sanity check for "no previous regular expression" state, 1994-09-14 22:25:15 +00:00
libcrypt Install shared libraries in ${DESTDIR}${SHLIBDIR} instead of in 1994-11-14 06:44:45 +00:00
libcurses tputs: (char) -> (int) 1994-12-10 23:02:33 +00:00
libedit Add LDADD+= -ltermcap 1994-10-12 02:06:02 +00:00
libf2c Remove z_abs. It is already in libm.a 1994-11-11 12:58:12 +00:00
libF77 Library for f2c (part 2 of 2) 1994-10-26 18:17:41 +00:00
libforms Fix some bugs with forms that have only text fields. 1994-11-13 07:43:43 +00:00
libI77 Library for f2c. (part 1 of 2) 1994-10-26 18:15:35 +00:00
libkvm A semicolon was lost. 1994-11-07 19:54:55 +00:00
libm Declare huge and tiny as volatile so that gcc doesn't evaluate huge*huge 1994-09-08 11:19:43 +00:00
libmd Added "const" to the arguments here and there. 1994-11-07 20:48:35 +00:00
libmytinfo Prototypes... 1994-12-10 22:56:53 +00:00
libncurses tputs prototypes... 1994-12-10 23:10:41 +00:00
libpam/modules Add skey supprot 1994-08-21 19:26:22 +00:00
libresolv BSD 4.4 Lite Lib Sources 1994-05-27 05:00:24 +00:00
librpc Make up for the fact that rpc headers are now installed from include. 1994-08-05 01:59:40 +00:00
librpcsvc Use ${ECHO} instead of echo' so that make -s' is fairly quiet. 1994-08-28 17:48:43 +00:00
libskey Remove extra newline. 1994-10-27 18:15:42 +00:00
libtelnet The big crypt removal - make libtelnet exportable. 1994-08-12 22:41:29 +00:00
libterm Correct the man page extent. 1994-08-08 19:26:23 +00:00
libtermcap tputs: (char) -> (int) 1994-12-10 22:01:25 +00:00
libutil Added $Id$ 1994-09-24 02:59:15 +00:00
liby BSD 4.4 Lite Lib Sources 1994-05-27 05:00:24 +00:00
msun Add missing z_abs. In BSD tradition this is in libm.a. 1994-11-11 12:56:27 +00:00
ncurses/ncurses termcap.h now belongs to system 1994-12-04 02:43:41 +00:00
rpcsvc Makefile to build librpcsvc. (All sources automatically generated.) 1994-08-07 23:21:08 +00:00
Makefile The start of a forms editor library. Currently implements text and 1994-11-13 06:45:44 +00:00
Makefile.inc From 1.1.5: define default shared library versions. For 2.0, use version 1994-08-04 22:44:00 +00:00