Skip to content

Commit 87c0577

Browse files
author
Stefan Esser
committed
some broken ftp servers return 32bit port numbers.
1 parent 29be52f commit 87c0577

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ext/standard/ftp_fopen_wrapper.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ php_stream * php_stream_url_wrap_ftp(php_stream_wrapper *wrapper, char *path, ch
352352
hoststart = ip;
353353

354354
/* pull out the MSB of the port */
355-
portno = (unsigned short) strtol(tpath, &ttpath, 10) * 256;
355+
portno = (unsigned short) strtoul(tpath, &ttpath, 10) * 256;
356356
if (ttpath == NULL) {
357357
/* didn't get correct response from PASV */
358358
goto errexit;
@@ -362,7 +362,7 @@ php_stream * php_stream_url_wrap_ftp(php_stream_wrapper *wrapper, char *path, ch
362362
goto errexit;
363363
tpath++;
364364
/* pull out the LSB of the port */
365-
portno += (unsigned short) strtol(tpath, &ttpath, 10);
365+
portno += (unsigned short) strtoul(tpath, &ttpath, 10);
366366
} else {
367367
/* parse epsv command (|||6446|) */
368368
for (i = 0, tpath = tmp_line + 4; *tpath; tpath++) {
@@ -375,7 +375,7 @@ php_stream * php_stream_url_wrap_ftp(php_stream_wrapper *wrapper, char *path, ch
375375
if (i < 3)
376376
goto errexit;
377377
/* pull out the port */
378-
portno = (unsigned short) strtol(tpath + 1, &ttpath, 10);
378+
portno = (unsigned short) strtoul(tpath + 1, &ttpath, 10);
379379
}
380380

381381
if (ttpath == NULL) {

0 commit comments

Comments
 (0)