~ubuntu-branches/ubuntu/vivid/musl/vivid

« back to all changes in this revision

Viewing changes to src/stat/utimensat.c

  • Committer: Package Import Robot
  • Author(s): Kevin Bortis
  • Date: 2014-05-26 22:45:52 UTC
  • mfrom: (4.1.4 sid)
  • Revision ID: package-import@ubuntu.com-20140526224552-qrtsct934q29xo0x
Tags: 1.1.4-1
* Import upstream version 1.1.4. (Closes: #754758)
* Fixes possible stack-based buffer overflow CVE-2014-3484 (Closes: #750815) 
* Includes fix for build regression on armhf and armel

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#include <sys/stat.h>
 
2
#include <sys/time.h>
 
3
#include <fcntl.h>
 
4
#include <errno.h>
2
5
#include "syscall.h"
3
6
 
4
7
int utimensat(int fd, const char *path, const struct timespec times[2], int flags)
5
8
{
6
 
        return syscall(SYS_utimensat, fd, path, times, flags);
 
9
        int r = __syscall(SYS_utimensat, fd, path, times, flags);
 
10
#ifdef SYS_futimesat
 
11
        if (r != -ENOSYS || flags) return __syscall_ret(r);
 
12
        struct timeval *tv = 0, tmp[2];
 
13
        if (times) {
 
14
                int i;
 
15
                tv = tmp;
 
16
                for (i=0; i<2; i++) {
 
17
                        if (times[i].tv_nsec >= 1000000000ULL) {
 
18
                                if (times[i].tv_nsec == UTIME_NOW &&
 
19
                                    times[1-i].tv_nsec == UTIME_NOW) {
 
20
                                        tv = 0;
 
21
                                        break;
 
22
                                }
 
23
                                if (times[i].tv_nsec == UTIME_OMIT)
 
24
                                        return __syscall_ret(-ENOSYS);
 
25
                                return __syscall_ret(-EINVAL);
 
26
                        }
 
27
                        tmp[i].tv_sec = times[i].tv_sec;
 
28
                        tmp[i].tv_usec = times[i].tv_nsec / 1000;
 
29
                }
 
30
        }
 
31
 
 
32
        r = __syscall(SYS_futimesat, fd, path, tv);
 
33
        if (r != -ENOSYS || fd != AT_FDCWD) return __syscall_ret(r);
 
34
        r = __syscall(SYS_utimes, path, tv);
 
35
#endif
 
36
        return __syscall_ret(r);
7
37
}