diff --git a/appl/ftp/ftp/cmds.c b/appl/ftp/ftp/cmds.c index 86b58ca1b..e9602627b 100644 --- a/appl/ftp/ftp/cmds.c +++ b/appl/ftp/ftp/cmds.c @@ -142,7 +142,7 @@ setpeer(int argc, char **argv) if (autologin) login(argv[1]); -#if (defined(unix) || defined(__unix__) || defined(__unix) || defined(_AIX) || defined(_CRAY) || defined(__NetBSD__)) && NBBY == 8 +#if (defined(unix) || defined(__unix__) || defined(__unix) || defined(_AIX) || defined(_CRAY) || defined(__NetBSD__) || defined(__APPLE__)) && NBBY == 8 /* * this ifdef is to keep someone form "porting" this to an incompatible * system and not checking this out. This way they have to think about it. @@ -150,22 +150,23 @@ setpeer(int argc, char **argv) overbose = verbose; if (debug == 0) verbose = -1; - if (command("SYST") == COMPLETE && overbose) { - char *cp, c; - cp = strchr(reply_string+4, ' '); + if (command("SYST") == COMPLETE && overbose && strlen(reply_string) > 4) { + char *cp, *p; + + cp = strdup(reply_string + 4); if (cp == NULL) - cp = strchr(reply_string+4, '\r'); - if (cp) { - if (cp[-1] == '.') - cp--; - c = *cp; - *cp = '\0'; + errx(1, "strdup: out of memory"); + p = strchr(cp, ' '); + if (p == NULL) + p = strchr(cp, '\r'); + if (p) { + if (p[-1] == '.') + p--; + *p = '\0'; } - printf("Remote system type is %s.\n", - reply_string+4); - if (cp) - *cp = c; + printf("Remote system type is %s.\n", cp); + free(cp); } if (!strncmp(reply_string, "215 UNIX Type: L8", 17)) { if (proxy)