Use snprintf(3) in place of unbounded sprintf(3) (prevent buffer overflow).
Use adequately sized buffer for error(s) (512 -> PATH_MAX + 512).
Fix the following style(9) nits while here:
- distfetch.c uses PATH_MAX while distextract.c uses MAXPATHLEN;
  standardize on one (PATH_MAX)
- Move $FreeBSD$ from comment to __FBSDID()
- Sort included headers (alphabetically, sys/* at top)
- Add missing header includes (e.g., <stdlib.h> for getenv(3),
  calloc(3)/malloc(3)/free(3), and atoi(3); <string.h> for strdup(3),
  strrchr(3), strsep(3), and strcmp(3); <ctype.h> for isspace(3); and
  <unistd.h> for chdir(2), etc.)
- Remove rogue newline at end of distfetch.c
- Don't declare variables in if-, while-, or other statement
NB: To prevent masking of prior declarations atop function
- Perform stack alignment for variable declarations
- Add missing function prototype for count_files() in distextract.c
- Break out single-line multivariable-declarations
NB: Aligning similarly-named variables with one-char difference(s)
NB: Minimizes diffs and makes future diffs more clear
- Use err(3) family of functions (requires s/int err;/int retval;/g)

Reviewed by:	nwhitehorn, julian
Merge remote-tracking branch 'origin/master' into hardened/current/upstream