From: Ilia Alshanetsky Date: Tue, 5 Oct 2004 23:53:09 +0000 (+0000) Subject: Fixed bug #30027 (Possible crash inside ftp_get()). X-Git-Tag: PRE_NEW_VM_GEN_PATCH~86 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e35adfe522062929021f4b0dd20a08ffc3ff2534;p=php Fixed bug #30027 (Possible crash inside ftp_get()). # Patch by cfield at affinitysolutions dot com --- diff --git a/ext/ftp/ftp.c b/ext/ftp/ftp.c index 0615e4ba68..345cbc5731 100644 --- a/ext/ftp/ftp.c +++ b/ext/ftp/ftp.c @@ -860,12 +860,12 @@ ftp_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type, ptr = s; } #else - while ((s = memchr(ptr, '\r', (e - ptr)))) { + while (e > ptr && (s = memchr(ptr, '\r', (e - ptr)))) { php_stream_write(outstream, ptr, (s - ptr)); if (*(s + 1) == '\n') { s++; + php_stream_putc(outstream, '\n'); } - php_stream_putc(outstream, '\n'); ptr = s + 1; } #endif