Commit graph

814 commits

Author SHA1 Message Date
Gina Peter Banyard
064ea9c505
Inlines the behaviour of php_mkdir_ex() into plain wrapper mkdir handler (#15520)
This effectively inlines the behaviour of php_mkdir_ex() which is a deprecated API from at least 17 years ago, and also fixes some of the return values.

This also removes a dependency on ext/standard
2024-09-23 00:40:02 +01:00
Gina Peter Banyard
f756b96e06
Make CSV deprecation less annoying to deal with (#15569) 2024-09-13 15:07:26 +01:00
David Carlier
fc01e2ee2b
Merge branch 'PHP-8.3' 2024-08-30 17:17:44 +01:00
David Carlier
d7d40b4c80
Merge branch 'PHP-8.2' into PHP-8.3 2024-08-30 17:17:20 +01:00
David Carlier
7db1a5843f
Fix GH-15653: fgetcsv overflow on length parameter.
close GH-15655
2024-08-30 17:16:57 +01:00
Gina Peter Bnayard
9147687b6d ext/standard/file.c: Use more appropriate types 2024-08-21 13:06:18 +01:00
Gina Peter Bnayard
369eeb73ca ext/standard/file.c: Use RETURN_BOOL() instead of if-else 2024-08-21 13:06:18 +01:00
Gina Peter Banyard
c818d944cf
ext/(standard|spl): Deprecate passing a non-empty string as the $enclosure parameter (#15362) 2024-08-12 16:09:56 +01:00
Peter Kokot
cf3b9fca8f
Sync #if/ifdef/defined (-Wundef) (#14623)
These are either define (to value 1) or undefined:
- __GNUC__
- DBA_CDB_BUILTIN
- DBA_GDBM
- HAVE_FORK
- HAVE_PUTENV
- HAVE_SETENV
- HAVE_SYS_SELECT_H
- HAVE_SYS_SOCKET_H
- HAVE_SYS_WAIT_H
- HAVE_UNSETENV
- RFC3678_API
- ZEND_ENABLE_ZVAL_LONG64
- ZTS

Follow-up of GH-5526
2024-06-24 19:37:07 +02:00
Peter Kokot
84a0da1574
Sync #if/ifdef/defined (#14508)
This syncs CPP macro conditions:
- _WIN32
- _WIN64
- HAVE_ALLOCA_H
- HAVE_ALPHASORT
- HAVE_ARPA_INET_H
- HAVE_CONFIG_H
- HAVE_DIRENT_H
- HAVE_DLFCN_H
- HAVE_GETTIMEOFDAY
- HAVE_LIBDL
- HAVE_POLL_H
- HAVE_PWD_H
- HAVE_SCANDIR
- HAVE_SYS_FILE_H
- HAVE_SYS_PARAM_H
- HAVE_SYS_SOCKET_H
- HAVE_SYS_TIME_H
- HAVE_SYS_TYPES_H
- HAVE_SYS_WAIT_H
- HAVE_UNISTD_H
- PHP_WIN32
- ZEND_WIN32

These are either undefined or defined to 1 in Autotools and Windows.

Follow up of GH-5526 (-Wundef).
2024-06-09 14:23:41 +02:00
Gina Peter Banyard
25a5146180
Clean-up unused headers (#14365)
* ext/mbstring.c: clean-up headers and include intrinsics
2024-06-01 17:12:42 +01:00
Peter Kokot
41e3044f48
Remove obsolete check for missing fclose declaration (#13360)
SunOS 4.1.4 from 1994 didn't have fclose declared in standard header
stdio.h. This doesn't need to be checked anymore, as fclose is part of
the C89+ standard and declaration is present on Solaris 10 (SunOS 5.10)
and later.
2024-02-09 18:11:49 +00:00
Cristian Rodríguez
927adfb1a6
Use a single version of mempcpy(3) (#12257)
While __php_mempcpy is only used by ext/standard/crypt_sha*, the
mempcpy "pattern" is used everywhere.

This commit removes __php_mempcpy, adds zend_mempcpy and transforms
open-coded parts into function calls.
2023-12-20 15:16:32 +00:00
Niels Dossche
5e02bca537 Remove always-true condition from php_copy_file_ctx()
srcstream is always checked before.
2023-12-12 16:43:43 +00:00
Jakub Zelenka
64ebadcac5
Fix GH-12151: str_getcsv ending with escape zero segfualt
Closes GH-12152
2023-09-08 10:58:55 +01:00
Jakub Zelenka
aff46d75e1
Fix GH-11982: str_getcsv returns null byte for unterminated quoted string
Closes GH-12047
2023-08-28 11:28:34 +01:00
George Peter Banyard
c9c846d63e Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix off-by-one bug when truncating tempnam prefix
2023-08-08 09:52:18 +01:00
George Peter Banyard
1ff59b9ad9 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix off-by-one bug when truncating tempnam prefix
2023-08-08 09:51:02 +01:00
Athos Ribeiro
cbfd73765a Fix off-by-one bug when truncating tempnam prefix
The tempnam documentation currently states that "Only the first 63
characters of the prefix are used, the rest are ignored". However when
the prefix is 64 characters-long, the current implementation fails to
strip the last character, diverging from the documented behavior. This
patch fixes the implementation so it matches the documented behavior for
that specific case where the prefix is 64 characters long.

Closes GH-11870

Signed-off-by: George Peter Banyard <girgias@php.net>
2023-08-08 09:46:27 +01:00
hanshenrik
3b0e61956e
fix file() flags error-check
the old flag check was flawed and would miss some flags, for example:
file(__FILE__, FILE_APPEND);
is invalid, but the old flags error check would miss it: https://3v4l.org/b2W9u

Closes GH-11483
2023-06-23 11:06:24 +02:00
Ilija Tovilo
44724430c1
Merge branch 'PHP-8.2'
* PHP-8.2:
  Propagate STREAM_DISABLE_OPEN_BASEDIR src flag to php_stream_stat_path_ex
2023-04-30 13:37:14 +02:00
Ilija Tovilo
de9b3f648c
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Propagate STREAM_DISABLE_OPEN_BASEDIR src flag to php_stream_stat_path_ex
2023-04-30 13:37:08 +02:00
Ilija Tovilo
8bf2d587d7
Propagate STREAM_DISABLE_OPEN_BASEDIR src flag to php_stream_stat_path_ex
Otherwise we can get open_basedir warnings from the stat call while still
performing the actual copy.

Fixes GH-11138
Closes GH-11156
2023-04-30 13:36:15 +02:00
Javier Eguiluz
732d92c0e5
[skip ci] Fix various typos and grammar issues (#11143) 2023-04-28 11:05:32 +02:00
Ilija Tovilo
439cea49fa
Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix buffer-overflow in php_fgetcsv() with \0 delimiter and enclosure
2023-03-25 17:43:12 +01:00
Ilija Tovilo
c5fe6c2eb9
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix buffer-overflow in php_fgetcsv() with \0 delimiter and enclosure
2023-03-25 17:43:07 +01:00
Ilija Tovilo
57029ce92e
Fix buffer-overflow in php_fgetcsv() with \0 delimiter and enclosure
Fixes oss-fuzz #57392
Closes GH-10923
2023-03-25 17:42:39 +01:00
Niels
11b612af6d
Rename PHP_STREAM_TO_ZVAL to PHP_STREAM_FROM_ZVAL (#10065) 2022-12-07 19:57:50 +01:00
Máté Kocsis
c573b8228a
Declare ext/standard constants in stubs - part 2 (#9426) 2022-08-26 14:40:48 +02:00
George Peter Banyard
4ccf0b0181
Make php_fgetcsv() return a HashTale instead of in-out zval param (#8936)
Also refactor what happens on an empty line to return NULL instead of setting the array to [NULL] which makes no design sense at all.
However, as this is the current behaviour create a BC Shim inline function to recreate this weird HashTable in the functions which currently use this API
2022-07-08 12:11:05 +01:00
Max Kellermann
6beee1a5bb
Disable the read buffer in file_get_contents()
The read buffer is useless here, it only hurts performance.

Closes GH-8547.
2022-05-16 16:21:29 +02:00
George Peter Banyard
5171cb435a Fix [-Wundef] warnings in standard extension 2022-04-01 15:48:41 +01:00
Aliaksandr Bystry
52e7e0f521 Fix bug #66588: SplFileObject::fgetcsv incorrectly returns a row on premature EOF
Make sure the behavior is the same regardless of whether there is
a trailing newline and whether the input is a stream or not.

Closes GH-7539.
2021-10-01 16:21:26 +02:00
Tim Starling
c96be7b8f2 Use ASCII lower case for misc case folding
Use ASCII case conversion instead of locale-dependent case conversion in
the following places:

* grapheme_stripos() and grapheme_strripos() in the "fast" path
* ldap_get_entries()
* oci_pconnect() for case folding of parameters when constructing a key
  into the connection or session pool
* SoapClient: case folding of function names
* get_meta_tags(): case conversion of property names
* http stream wrapper: header names
* phpinfo(): anchor names
* php_verror(): docref URLs
* rfc1867.c: Content-Type boundary parameter name
* streams.c: stream protocol names

Using locale-dependent case folding for these cases is either
unnecessary or actively incorrect. These functions could have
misbehaved when used with certain locales (e.g. Turkish).

Closes GH-7511.
2021-09-24 09:20:08 +02:00
Nikita Popov
14f599ea7d Use zend_long for resource ID
Currently, resource IDs are limited to 32-bits. As resource IDs
are not reused, this means that resource ID overflow for
long-running processes is very possible.

This patch switches resource IDs to use zend_long instead, which
means that on 64-bit systems, 64-bit resource IDs will be used.
This makes resource ID overflow practically impossible.

The tradeoff is an 8 byte increase in zend_resource size.

Closes GH-7436.
2021-08-31 14:58:59 +02:00
Ikko Ashimine
6e5771148d Fix typo in file.c
apostrohpe -> apostrophe
2021-08-25 09:51:32 +02:00
Nikita Popov
6e20f0f3a2 Returned interned string from fgetc()
Make use of single-character interned strings.
2021-08-16 11:15:23 +02:00
Nikita Popov
232aa34b9f Deprecate auto_detect_line_endings
Part of https://wiki.php.net/rfc/deprecations_php_8_1.
2021-07-09 10:05:57 +02:00
Nikita Popov
92f6e21523 Deprecate FILE_BINARY and FILE_TEXT constants
These constants have no effect.

Part of https://wiki.php.net/rfc/deprecations_php_8_1.
2021-07-08 15:34:51 +02:00
Nikita Popov
076fbd360a Minor fgetcsv cleanup
Reduce some variable scopes.
2021-07-06 12:37:22 +02:00
Patrick Allaert
aff365871a Fixed some spaces used instead of tabs 2021-06-29 11:30:26 +02:00
George Peter Banyard
aca6aefd85
Remove 'register' type qualifier (#6980)
The compiler should be smart enough to optimize this on its own
2021-05-14 13:38:01 +01:00
KsaR
01b3fc03c3
Update http->https in license (#6945)
1. Update: http://www.php.net/license/3_01.txt to https, as there is anyway server header "Location:" to https.
2. Update few license 3.0 to 3.01 as 3.0 states "php 5.1.1, 4.1.1, and earlier".
3. In some license comments is "at through the world-wide-web" while most is without "at", so deleted.
4. fixed indentation in some files before |
2021-05-06 12:16:35 +02:00
David Gebler
cbcfd86026 Add fsync() and fdatasync() functions
fsync is a straightforward wrapper around the same C function
(implemented on Windows API as _commit() with identical signature).

From the man pages:

    fsync() transfers ("flushes") all modified in-core data of (i.e.,
    modified buffer cache pages for) the file referred to by the file
    descriptor fd to the disk device (or other permanent storage
    device) so that all changed information can be retrieved even if
    the system crashes or is rebooted.  This includes writing through
    or flushing a disk cache if present.  The call blocks until the
    device reports that the transfer has completed.

RFC: https://wiki.php.net/rfc/fsync_function

Closes GH-6650.
2021-04-13 16:09:22 +02:00
George Peter Banyard
5caaf40b43
Introduce pseudo-keyword ZEND_FALLTHROUGH
And use it instead of comments
2021-04-07 00:46:29 +01:00
George Peter Banyard
8560d168d3
Align types with the output of zend_hash_num_elements() 2021-03-29 14:20:22 +01:00
Cameron Hall
5b29eba7ca Fix #42357: fputcsv() has an optional parameter for line endings
fputcsv does not terminate lines correctly as per RFC 41801[1]. After adding a new parameter fputcsv may now use a user defined line ending,. In order to maintain backwards compatibility fputcsv() still terminates lines with "\n" by default.

Also fixes: #46367[2], #62770[3]
Ref: #42357[4]

[1] <https://tools.ietf.org/html/rfc4180>
[2] <https://bugs.php.net/bug.php?id=46367>
[3] <https://bugs.php.net/bug.php?id=62770>
[4] <https://bugs.php.net/bug.php?id=42357>
2021-03-29 13:34:38 +01:00
Dmitry Stogov
13e4ce386b Improve SPL directory and stat() cache using zend_srting* instead of char* 2021-02-26 02:28:46 +03:00
Christoph M. Becker
eea4aac1a0 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80654: file_get_contents() maxlen fails above (2**31)-1 bytes
2021-02-01 13:01:27 +01:00
Christoph M. Becker
766d5846b1 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80654: file_get_contents() maxlen fails above (2**31)-1 bytes
2021-02-01 13:00:22 +01:00