bin/107676: file -p does not work
Maxim Konovalov
maxim at macomnet.ru
Mon Jan 8 09:00:28 PST 2007
The following reply was made to PR bin/107676; it has been noted by GNATS.
From: Maxim Konovalov <maxim at macomnet.ru>
To: bug-followup at freebsd.org
Cc:
Subject: Re: bin/107676: file -p does not work
Date: Mon, 8 Jan 2007 19:51:35 +0300 (MSK)
On Mon, 8 Jan 2007, 16:00-0000, Ricardo Nabinger Sanchez wrote:
> The following reply was made to PR bin/107676; it has been noted by GNATS.
>
> From: Ricardo Nabinger Sanchez <rnsanchez at wait4.org>
> To: "Dr. Markus Waldeck" <waldeck at gmx.de>
> Cc: freebsd-gnats-submit at FreeBSD.org
> Subject: Re: bin/107676: file -p does not work
> Date: Mon, 8 Jan 2007 13:53:35 -0200
>
> On Mon, 8 Jan 2007 13:45:01 GMT
> "Dr. Markus Waldeck" <waldeck at gmx.de> wrote:
>
> > >Description:
> > The option "-p" does not work because the utimes system call fails.
> >
> > ktrace:
> > 28598 file CALL utimes(0xbfbfed78,0xbfbfe6d0)
> > 28598 file RET utimes -1 errno 22 Invalid argument
> >
> > truss:
> > utimes("FILENAME",{1168184675.-1077942524, 1166372455.000001}) ERR#22
> > 'Invalid argument'
>
> Also happens on 6.1-RELEASE i386:
>
> % truss file - p main.c
> ...
> lstat("main.c",0xbfbee200) = 0 (0x0)
> open("main.c",0x0,027757561000) = 3 (0x3)
> read(0x3,0xbfbee260,0x10000) = 6455 (0x1937)
> break(0x8051000) = 0 (0x0)
> lseek(3,0x0,SEEK_SET) = 0 (0x0)
> close(3) = 0 (0x0)
> utimes("main.c",{1168271467 -1077943672}) ERR#22 'Invalid argument'
> ...
Quick and mostly untested patch:
Index: magic.c
===================================================================
RCS file: /home/ncvs/src/contrib/file/magic.c,v
retrieving revision 1.1.1.3
diff -u -p -r1.1.1.3 magic.c
--- magic.c 19 Jun 2006 07:52:12 -0000 1.1.1.3
+++ magic.c 8 Jan 2007 16:46:12 -0000
@@ -195,6 +195,7 @@ close_and_restore(const struct magic_set
*/
#ifdef HAVE_UTIMES
struct timeval utsbuf[2];
+ memset(utsbuf, 0, sizeof(struct timeval) * 2);
utsbuf[0].tv_sec = sb->st_atime;
utsbuf[1].tv_sec = sb->st_mtime;
@@ -202,6 +203,7 @@ close_and_restore(const struct magic_set
#elif defined(HAVE_UTIME_H) || defined(HAVE_SYS_UTIME_H)
struct utimbuf utbuf;
+ memset(&utbuf, 0, sizeof(struct utimbuf));
utbuf.actime = sb->st_atime;
utbuf.modtime = sb->st_mtime;
(void) utime(name, &utbuf); /* don't care if loses */
%%%
--
Maxim Konovalov
More information about the freebsd-bugs
mailing list