pecl-php-uploadprogress | An extension to track progress of a file upload | File Upload library
kandi X-RAY | pecl-php-uploadprogress Summary
kandi X-RAY | pecl-php-uploadprogress Summary
A PHP extension to track progress of a file upload, including details on the speed of the upload, estimated time remaining, and access to the contents of the file as it is being uploaded.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of pecl-php-uploadprogress
pecl-php-uploadprogress Key Features
pecl-php-uploadprogress Examples and Code Snippets
Community Discussions
Trending Discussions on pecl-php-uploadprogress
QUESTION
Background: I have a webapp that uses uploadprogress and it just caused a segmentation fault. Investigating about the problem I found a bug report that points the problem down to a line in the code https://bugs.php.net/bug.php?id=79584
In this code I also saw, that they use strcpy. The function is used there for many years already so I guess it has been checked against security rules, but I am not a C programmer and my knowledge is very limited. I also found mentions that it sometimes can be legitimate to still use strcpy without causing any security issues.
Now I wonder if that's the case in this special package. Is it safe that the code contains this function or not?
...ANSWER
Answered 2020-May-12 at 17:47The bug produced by that commit has absolutely nothing to do with the safety of strcpy
(or lack thereof).
strcpy
is not safe unless you have some way to ensure that the destination object is big enough to hold the source (including its NUL terminator). If you do that, then it is as safe as your checks are.
Other than the confusion with dereference operators, the methodology of the linked code is adequate. Measuring strlen
of the source string and adding one is a sufficient method to determine the length required; malloc
of this amount is a sufficient method for allocating this much space. To that extent, strcpy(malloc(strlen(src) + 1), src)
is as safe as you're going to find in C (aside from the cheekiness of not testing the return code of malloc
for NULL
; in real production code, you should do that, or use a malloc
wrapper like emalloc
in the PHP source).
However, strdup(src)
is much more concise and readable, and its conciseness makes typos less probable. Personally, I would recommend to always use strdup
for such cases; if you are worried that your target platform doesn't contain an implementation, it's easy enough to shim.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install pecl-php-uploadprogress
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page