Fix utime/utimes when passed a NULL pointer.
Bug: 11383777 Change-Id: If944a42f3adfa8a6ce91c167c249e009ed63300a
This commit is contained in:
@@ -34,9 +34,13 @@
|
||||
|
||||
int utimes(const char* path, const timeval tv[2]) {
|
||||
timespec ts[2];
|
||||
if (!timespec_from_timeval(ts[0], tv[0]) || !timespec_from_timeval(ts[1], tv[1])) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
timespec* ts_ptr = NULL;
|
||||
if (tv != NULL) {
|
||||
if (!timespec_from_timeval(ts[0], tv[0]) || !timespec_from_timeval(ts[1], tv[1])) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
ts_ptr = ts;
|
||||
}
|
||||
return utimensat(AT_FDCWD, path, ts, 0);
|
||||
return utimensat(AT_FDCWD, path, ts_ptr, 0);
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _UTIME_H_
|
||||
#define _UTIME_H_
|
||||
|
||||
@@ -34,9 +35,8 @@
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
extern int utime(const char *, const struct utimbuf *);
|
||||
extern int utime(const char*, const struct utimbuf*);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* _UTIME_H_ */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user