Thread View: comp.bugs.2bsd
1 messages
1 total messages
Started by authorplaceholder
Tue, 05 May 1987 00:48
Minor bug in getwd()
Author: authorplaceholder
Date: Tue, 05 May 1987 00:48
Date: Tue, 05 May 1987 00:48
49 lines
1830 bytes
1830 bytes
Subject: Getwd() returns an array with a garbage character at the end. Index: /usr/src/lib/c/gen/getwd.c 2.9bsd Description: Getwd() returns an array with a garbage character at the end. This only occurs when the length of a particular directory is exactly 14 (DIRSIZ). There is no NULL terminated array in this case, and no provisions are made for it. Repeat-By: Make a directory of length 14 characters. Cd to that directory. Run a program that displays the output from the getwd() call. Take a look at the output using any favorite program that displays trash characters. Fix: 22c22 < char *strcpy(); --- > char *strcpy(),*strncpy(); 29a30 > char name[DIRSIZ+1]; /* "clean" name */ 36a38 > int n; 79c81,89 < pnptr = prepend(PATHSEP, prepend(dir.d_name, pnptr)); --- > /* > * pnptr = prepend(PATHSEP, prepend(dir.d_name, pnptr)); > */ > n = strlen(dir.d_name); > if (n > DIRSIZ) > n = DIRSIZ; > strncpy(name,dir.d_name,n); > name[n] = 0; > pnptr = prepend(PATHSEP, prepend(name, pnptr)); Comments: Since 2.9bsd only looks at the first 14 characters, this bug hardly breaks anything. Kevin W. Thomas UUCP: ihnp4!occrsh!uokmet!kwthomas ihnp4!okstate!uokmax!uokmet!kwthomas
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads