svn commit: r359736 - in head: etc/mtree share/mk share/zoneinfo share/zoneinfo/tests

2020-04-08 Thread Xin LI
Author: delphij
Date: Thu Apr  9 05:11:18 2020
New Revision: 359736
URL: https://svnweb.freebsd.org/changeset/base/359736

Log:
  Always install backward compatibility timezones, as they are installed
  on all major Linux distributions as well as NetBSD and OpenBSD.
  
  Remove the undocumented ZONEINFO_OLD_TIMEZONES_SUPPORT and the deprecated
  OLDTIMEZONES knobs as they are now the default.
  
  Reviewed by:  ngie, rgrimes
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D24306

Modified:
  head/etc/mtree/BSD.usr.dist
  head/share/mk/src.opts.mk
  head/share/zoneinfo/Makefile
  head/share/zoneinfo/tests/Makefile

Modified: head/etc/mtree/BSD.usr.dist
==
--- head/etc/mtree/BSD.usr.dist Thu Apr  9 04:50:19 2020(r359735)
+++ head/etc/mtree/BSD.usr.dist Thu Apr  9 05:11:18 2020(r359736)
@@ -1253,15 +1253,25 @@
 ..
 Australia
 ..
+Brazil
+..
+Canada
+..
+Chile
+..
 Etc
 ..
 Europe
 ..
 Indian
 ..
+Mexico
+..
 Pacific
 ..
 SystemV
+..
+US
 ..
 ..
 ..

Modified: head/share/mk/src.opts.mk
==
--- head/share/mk/src.opts.mk   Thu Apr  9 04:50:19 2020(r359735)
+++ head/share/mk/src.opts.mk   Thu Apr  9 05:11:18 2020(r359736)
@@ -218,7 +218,6 @@ __DEFAULT_NO_OPTIONS = \
 SORT_THREADS \
 SVN \
 ZONEINFO_LEAPSECONDS_SUPPORT \
-ZONEINFO_OLD_TIMEZONES_SUPPORT \
 
 # LEFT/RIGHT. Left options which default to "yes" unless their corresponding
 # RIGHT option is disabled.
@@ -466,7 +465,6 @@ MK_GOOGLETEST:= no
 
 .if ${MK_ZONEINFO} == "no"
 MK_ZONEINFO_LEAPSECONDS_SUPPORT:= no
-MK_ZONEINFO_OLD_TIMEZONES_SUPPORT:= no
 .endif
 
 .if ${MK_CROSS_COMPILER} == "no"

Modified: head/share/zoneinfo/Makefile
==
--- head/share/zoneinfo/MakefileThu Apr  9 04:50:19 2020
(r359735)
+++ head/share/zoneinfo/MakefileThu Apr  9 05:11:18 2020
(r359736)
@@ -40,11 +40,6 @@ CONTRIBDIR=  ${SRCTOP}/contrib/tzdata/
 MK_ZONEINFO_LEAPSECONDS_SUPPORT= yes
 .endif
 
-.if defined(OLDTIMEZONES)
-.warning "Using backwards compatibility variable for OLDTIMEZONES; please use 
WITH_ZONEINFO_OLD_TIMEZONES_SUPPORT instead"
-MK_ZONEINFO_OLD_TIMEZONES_SUPPORT= yes
-.endif
-
 .if ${MK_ZONEINFO_LEAPSECONDS_SUPPORT} != "no"
 LEAPFILE=  -L ${CONTRIBDIR}leapseconds
 .else
@@ -53,12 +48,9 @@ LEAPFILE=
 
 TZFILES=   africa antarctica asia australasia etcetera europe \
factory northamerica southamerica
+TZFILES+=  backward systemv
 POSIXRULES=America/New_York
 
-.if ${MK_ZONEINFO_OLD_TIMEZONES_SUPPORT} != "no"
-TZFILES+=  backward systemv
-.endif
-
 TZFILES:=  ${TZFILES:S/^/${CONTRIBDIR}/}
 
 TZBUILDDIR=${.OBJDIR}/builddir
@@ -78,10 +70,7 @@ TZBUILDSUBDIRS=  \
Indian \
Pacific \
SystemV
-
-.if ${MK_ZONEINFO_OLD_TIMEZONES_SUPPORT} != "no"
 TZBUILDSUBDIRS+= US Mexico Chile Canada Brazil
-.endif
 
 .if !defined(_SKIP_BUILD)
 all: zoneinfo

Modified: head/share/zoneinfo/tests/Makefile
==
--- head/share/zoneinfo/tests/Makefile  Thu Apr  9 04:50:19 2020
(r359735)
+++ head/share/zoneinfo/tests/Makefile  Thu Apr  9 05:11:18 2020
(r359736)
@@ -8,10 +8,8 @@ PACKAGE=   tests
 
 FILESGROUPS+=  TESTFILES
 
-.if ${MK_ZONEINFO_OLD_TIMEZONES_SUPPORT} != "no"
 ATF_TESTS_SH+= backward_test
 TESTFILES+=backward
-.endif
 
 TESTFILES+=zoneinfo_common.sh
 TESTFILESPACKAGE= ${PACKAGE}
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r359640 - stable/12/lib/liblzma

2020-04-04 Thread Xin LI
Author: delphij
Date: Sun Apr  5 04:01:11 2020
New Revision: 359640
URL: https://svnweb.freebsd.org/changeset/base/359640

Log:
  Disable use of bswapxx with GCC.

Modified:
  stable/12/lib/liblzma/config.h

Modified: stable/12/lib/liblzma/config.h
==
--- stable/12/lib/liblzma/config.h  Sun Apr  5 03:26:40 2020
(r359639)
+++ stable/12/lib/liblzma/config.h  Sun Apr  5 04:01:11 2020
(r359640)
@@ -312,15 +312,15 @@
 #define HAVE__MM_MOVEMASK_EPI8 1
 #endif
 
+#if defined(__clang__) && defined(__FreeBSD__)
 /* Define to 1 if the GNU C extension __builtin_assume_aligned is supported.
*/
-#if defined(__clang__) && defined(__FreeBSD__)
 #define HAVE___BUILTIN_ASSUME_ALIGNED 1
-#endif
 
 /* Define to 1 if the GNU C extensions __builtin_bswap16/32/64 are supported.
*/
 #define HAVE___BUILTIN_BSWAPXX 1
+#endif
 
 /* Define to the sub-directory where libtool stores uninstalled libraries. */
 #define LT_OBJDIR ".libs/"
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r359639 - stable/12/lib/liblzma

2020-04-04 Thread Xin LI
Author: delphij
Date: Sun Apr  5 03:26:40 2020
New Revision: 359639
URL: https://svnweb.freebsd.org/changeset/base/359639

Log:
  Workaround for GCC.

Modified:
  stable/12/lib/liblzma/config.h

Modified: stable/12/lib/liblzma/config.h
==
--- stable/12/lib/liblzma/config.h  Sun Apr  5 02:45:54 2020
(r359638)
+++ stable/12/lib/liblzma/config.h  Sun Apr  5 03:26:40 2020
(r359639)
@@ -314,7 +314,9 @@
 
 /* Define to 1 if the GNU C extension __builtin_assume_aligned is supported.
*/
+#if defined(__clang__) && defined(__FreeBSD__)
 #define HAVE___BUILTIN_ASSUME_ALIGNED 1
+#endif
 
 /* Define to 1 if the GNU C extensions __builtin_bswap16/32/64 are supported.
*/
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r359638 - stable/12/sbin/fsck_msdosfs

2020-04-04 Thread Xin LI
Author: delphij
Date: Sun Apr  5 02:45:54 2020
New Revision: 359638
URL: https://svnweb.freebsd.org/changeset/base/359638

Log:
  MFC r357716: Use humanize_number to format available and bad space size

Modified:
  stable/12/sbin/fsck_msdosfs/Makefile
  stable/12/sbin/fsck_msdosfs/check.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sbin/fsck_msdosfs/Makefile
==
--- stable/12/sbin/fsck_msdosfs/MakefileSun Apr  5 02:27:49 2020
(r359637)
+++ stable/12/sbin/fsck_msdosfs/MakefileSun Apr  5 02:45:54 2020
(r359638)
@@ -9,6 +9,7 @@ PROG=   fsck_msdosfs
 MAN=   fsck_msdosfs.8
 SRCS=  main.c check.c boot.c fat.c dir.c fsutil.c
 
-CFLAGS+= -I${FSCK}
+CFLAGS+= -I${FSCK} -DHAVE_LIBUTIL_H
+LIBADD=util
 
 .include 

Modified: stable/12/sbin/fsck_msdosfs/check.c
==
--- stable/12/sbin/fsck_msdosfs/check.c Sun Apr  5 02:27:49 2020
(r359637)
+++ stable/12/sbin/fsck_msdosfs/check.c Sun Apr  5 02:45:54 2020
(r359638)
@@ -33,6 +33,9 @@ static const char rcsid[] =
   "$FreeBSD$";
 #endif /* not lint */
 
+#ifdef HAVE_LIBUTIL_H
+#include 
+#endif
 #include 
 #include 
 #include 
@@ -126,15 +129,38 @@ checkfilesys(const char *fname)
mod |= FSERROR;
}
 
+#ifdef HAVE_LIBUTIL_H
+   char freestr[7], badstr[7];
+
+   int64_t freebytes = boot.NumFree * boot.ClusterSize;
+   humanize_number(freestr, sizeof(freestr), freebytes, "",
+   HN_AUTOSCALE, HN_DECIMAL | HN_IEC_PREFIXES);
+   if (boot.NumBad) {
+   int64_t badbytes = boot.NumBad * boot.ClusterSize;
+
+   humanize_number(badstr, sizeof(badstr), badbytes, "",
+   HN_AUTOSCALE, HN_B | HN_DECIMAL | HN_IEC_PREFIXES);
+
+   pwarn("%d files, %sB free (%d clusters), %sB bad (%d 
clusters)\n",
+ boot.NumFiles,
+ freestr, boot.NumFree,
+ badstr, boot.NumBad);
+   } else {
+   pwarn("%d files, %sB free (%d clusters)\n",
+ boot.NumFiles,
+ freestr, boot.NumFree);
+   }
+#else
if (boot.NumBad)
-   pwarn("%d files, %d free (%d clusters), %d bad (%d clusters)\n",
+   pwarn("%d files, %d KiB free (%d clusters), %d KiB bad (%d 
clusters)\n",
  boot.NumFiles,
  boot.NumFree * boot.ClusterSize / 1024, boot.NumFree,
  boot.NumBad * boot.ClusterSize / 1024, boot.NumBad);
else
-   pwarn("%d files, %d free (%d clusters)\n",
+   pwarn("%d files, %d KiB free (%d clusters)\n",
  boot.NumFiles,
  boot.NumFree * boot.ClusterSize / 1024, boot.NumFree);
+#endif
 
if (mod && (mod & FSERROR) == 0) {
if (mod & FSDIRTY) {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r359637 - in stable/12: contrib/file contrib/file/doc contrib/file/m4 contrib/file/magic contrib/file/magic/Magdir contrib/file/python contrib/file/src contrib/file/tests lib/libmagic

2020-04-04 Thread Xin LI
Author: delphij
Date: Sun Apr  5 02:27:49 2020
New Revision: 359637
URL: https://svnweb.freebsd.org/changeset/base/359637

Log:
  MFC r357757: MFV r357712: file 5.38.

Added:
  stable/12/contrib/file/magic/Magdir/forth
 - copied unchanged from r357757, head/contrib/file/magic/Magdir/forth
  stable/12/contrib/file/magic/Magdir/git
 - copied unchanged from r357757, head/contrib/file/magic/Magdir/git
  stable/12/contrib/file/magic/Magdir/modulefile
 - copied unchanged from r357757, head/contrib/file/magic/Magdir/modulefile
  stable/12/contrib/file/magic/Magdir/openfst
 - copied unchanged from r357757, head/contrib/file/magic/Magdir/openfst
  stable/12/contrib/file/magic/Magdir/opentimestamps
 - copied unchanged from r357757, 
head/contrib/file/magic/Magdir/opentimestamps
  stable/12/contrib/file/magic/Magdir/pmem
 - copied unchanged from r357757, head/contrib/file/magic/Magdir/pmem
  stable/12/contrib/file/magic/Magdir/rst
 - copied unchanged from r357757, head/contrib/file/magic/Magdir/rst
  stable/12/contrib/file/magic/Magdir/sosi
 - copied unchanged from r357757, head/contrib/file/magic/Magdir/sosi
  stable/12/contrib/file/src/is_csv.c
 - copied unchanged from r357757, head/contrib/file/src/is_csv.c
Modified:
  stable/12/contrib/file/ChangeLog
  stable/12/contrib/file/Makefile.in
  stable/12/contrib/file/README
  stable/12/contrib/file/aclocal.m4
  stable/12/contrib/file/compile
  stable/12/contrib/file/config.guess
  stable/12/contrib/file/config.h.in
  stable/12/contrib/file/config.sub
  stable/12/contrib/file/configure
  stable/12/contrib/file/configure.ac
  stable/12/contrib/file/depcomp
  stable/12/contrib/file/doc/Makefile.in
  stable/12/contrib/file/doc/file.man
  stable/12/contrib/file/doc/libmagic.man
  stable/12/contrib/file/doc/magic.man
  stable/12/contrib/file/ltmain.sh
  stable/12/contrib/file/m4/libtool.m4
  stable/12/contrib/file/m4/ltoptions.m4
  stable/12/contrib/file/m4/ltsugar.m4
  stable/12/contrib/file/m4/ltversion.m4
  stable/12/contrib/file/m4/lt~obsolete.m4
  stable/12/contrib/file/magic/Magdir/android
  stable/12/contrib/file/magic/Magdir/animation
  stable/12/contrib/file/magic/Magdir/apple
  stable/12/contrib/file/magic/Magdir/archive
  stable/12/contrib/file/magic/Magdir/audio
  stable/12/contrib/file/magic/Magdir/bsi
  stable/12/contrib/file/magic/Magdir/c-lang
  stable/12/contrib/file/magic/Magdir/cad
  stable/12/contrib/file/magic/Magdir/commands
  stable/12/contrib/file/magic/Magdir/compress
  stable/12/contrib/file/magic/Magdir/console
  stable/12/contrib/file/magic/Magdir/database
  stable/12/contrib/file/magic/Magdir/elf
  stable/12/contrib/file/magic/Magdir/espressif
  stable/12/contrib/file/magic/Magdir/filesystems
  stable/12/contrib/file/magic/Magdir/fonts
  stable/12/contrib/file/magic/Magdir/frame
  stable/12/contrib/file/magic/Magdir/games
  stable/12/contrib/file/magic/Magdir/gimp
  stable/12/contrib/file/magic/Magdir/icc
  stable/12/contrib/file/magic/Magdir/images
  stable/12/contrib/file/magic/Magdir/javascript
  stable/12/contrib/file/magic/Magdir/kml
  stable/12/contrib/file/magic/Magdir/linux
  stable/12/contrib/file/magic/Magdir/macintosh
  stable/12/contrib/file/magic/Magdir/mail.news
  stable/12/contrib/file/magic/Magdir/map
  stable/12/contrib/file/magic/Magdir/msdos
  stable/12/contrib/file/magic/Magdir/msooxml
  stable/12/contrib/file/magic/Magdir/ole2compounddocs
  stable/12/contrib/file/magic/Magdir/pdf
  stable/12/contrib/file/magic/Magdir/python
  stable/12/contrib/file/magic/Magdir/rpi
  stable/12/contrib/file/magic/Magdir/ruby
  stable/12/contrib/file/magic/Magdir/sgml
  stable/12/contrib/file/magic/Magdir/sniffer
  stable/12/contrib/file/magic/Magdir/ssh
  stable/12/contrib/file/magic/Magdir/uuencode
  stable/12/contrib/file/magic/Magdir/varied.script
  stable/12/contrib/file/magic/Magdir/vax
  stable/12/contrib/file/magic/Magdir/windows
  stable/12/contrib/file/magic/Magdir/wordprocessors
  stable/12/contrib/file/magic/Magdir/zip
  stable/12/contrib/file/magic/Makefile.am
  stable/12/contrib/file/magic/Makefile.in
  stable/12/contrib/file/missing
  stable/12/contrib/file/python/Makefile.in
  stable/12/contrib/file/src/Makefile.am
  stable/12/contrib/file/src/Makefile.in
  stable/12/contrib/file/src/apprentice.c
  stable/12/contrib/file/src/ascmagic.c
  stable/12/contrib/file/src/buffer.c
  stable/12/contrib/file/src/compress.c
  stable/12/contrib/file/src/encoding.c
  stable/12/contrib/file/src/file.c
  stable/12/contrib/file/src/file.h
  stable/12/contrib/file/src/file_opts.h
  stable/12/contrib/file/src/fsmagic.c
  stable/12/contrib/file/src/funcs.c
  stable/12/contrib/file/src/magic.h.in
  stable/12/contrib/file/src/readcdf.c
  stable/12/contrib/file/src/readelf.c
  stable/12/contrib/file/src/seccomp.c
  stable/12/contrib/file/src/vasprintf.c
  stable/12/contrib/file/tests/JW07022A.mp3.result
  stable/12/contrib/file/tests/Makefile.in
  stable/12/contrib/file/tests/test.c
  stable/12/lib/libmagic/Makefile

svn commit: r359636 - in stable/12/contrib/xz/src: common xz

2020-04-04 Thread Xin LI
Author: delphij
Date: Sun Apr  5 02:08:17 2020
New Revision: 359636
URL: https://svnweb.freebsd.org/changeset/base/359636

Log:
  MFC r357609: MFV r357608: Limit memory usage in xz(1) instead of in tuklib.

Modified:
  stable/12/contrib/xz/src/common/tuklib_physmem.c
  stable/12/contrib/xz/src/xz/hardware.c
  stable/12/contrib/xz/src/xz/xz.1
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/contrib/xz/src/common/tuklib_physmem.c
==
--- stable/12/contrib/xz/src/common/tuklib_physmem.cSun Apr  5 01:53:35 
2020(r359635)
+++ stable/12/contrib/xz/src/common/tuklib_physmem.cSun Apr  5 02:08:17 
2020(r359636)
@@ -45,7 +45,6 @@
 #  include 
 
 #elif defined(TUKLIB_PHYSMEM_SYSCONF)
-#  include 
 #  include 
 
 #elif defined(TUKLIB_PHYSMEM_SYSCTL)
@@ -146,16 +145,13 @@ tuklib_physmem(void)
 #elif defined(TUKLIB_PHYSMEM_SYSCONF)
const long pagesize = sysconf(_SC_PAGESIZE);
const long pages = sysconf(_SC_PHYS_PAGES);
-   if (pagesize != -1 && pages != -1) {
+   if (pagesize != -1 && pages != -1)
// According to docs, pagesize * pages can overflow.
// Simple case is 32-bit box with 4 GiB or more RAM,
// which may report exactly 4 GiB of RAM, and "long"
// being 32-bit will overflow. Casting to uint64_t
// hopefully avoids overflows in the near future.
ret = (uint64_t)pagesize * (uint64_t)pages;
-   if (ret > SIZE_T_MAX)
-   ret = SIZE_T_MAX;
-   }
 
 #elif defined(TUKLIB_PHYSMEM_SYSCTL)
int name[2] = {

Modified: stable/12/contrib/xz/src/xz/hardware.c
==
--- stable/12/contrib/xz/src/xz/hardware.c  Sun Apr  5 01:53:35 2020
(r359635)
+++ stable/12/contrib/xz/src/xz/hardware.c  Sun Apr  5 02:08:17 2020
(r359636)
@@ -68,8 +68,38 @@ hardware_memlimit_set(uint64_t new_memlimit,
new_memlimit = (uint32_t)new_memlimit * total_ram / 100;
}
 
-   if (set_compress)
+   if (set_compress) {
memlimit_compress = new_memlimit;
+
+#if SIZE_MAX == UINT32_MAX
+   // FIXME?
+   //
+   // When running a 32-bit xz on a system with a lot of RAM and
+   // using a percentage-based memory limit, the result can be
+   // bigger than the 32-bit address space. Limiting the limit
+   // below SIZE_MAX for compression (not decompression) makes
+   // xz lower the compression settings (or number of threads)
+   // to a level that *might* work. In practice it has worked
+   // when using a 64-bit kernel that gives full 4 GiB address
+   // space to 32-bit programs. In other situations this might
+   // still be too high, like 32-bit kernels that may give much
+   // less than 4 GiB to a single application.
+   //
+   // So this is an ugly hack but I will keep it here while
+   // it does more good than bad.
+   //
+   // Use a value less than SIZE_MAX so that there's some room
+   // for the xz program and so on. Don't use 4000 MiB because
+   // it could look like someone mixed up base-2 and base-10.
+   const uint64_t limit_max = UINT64_C(4020) << 20;
+
+   // UINT64_MAX is a special case for the string "max" so
+   // that has to be handled specially.
+   if (memlimit_compress != UINT64_MAX
+   && memlimit_compress > limit_max)
+   memlimit_compress = limit_max;
+#endif
+   }
 
if (set_decompress)
memlimit_decompress = new_memlimit;

Modified: stable/12/contrib/xz/src/xz/xz.1
==
--- stable/12/contrib/xz/src/xz/xz.1Sun Apr  5 01:53:35 2020
(r359635)
+++ stable/12/contrib/xz/src/xz/xz.1Sun Apr  5 02:08:17 2020
(r359636)
@@ -1005,6 +1005,25 @@ instead of
 until the details have been decided.
 .RE
 .IP ""
+For 32-bit
+.BR xz
+there is a special case: if the
+.I limit
+would be over
+.BR "4020\ MiB" ,
+the
+.I limit
+is set to
+.BR "4020\ MiB" .
+(The values
+.B 0
+and
+.B max
+aren't affected by this.
+A similar feature doesn't exist for decompression.)
+This can be helpful when a 32-bit executable has access
+to 4\ GiB address space while hopefully doing no harm in other situations.
+.IP ""
 See also the section
 .BR "Memory usage" .
 .TP
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r359635 - in stable/12: contrib/xz contrib/xz/src/common contrib/xz/src/liblzma/api contrib/xz/src/liblzma/api/lzma contrib/xz/src/liblzma/check contrib/xz/src/liblzma/common contrib/xz...

2020-04-04 Thread Xin LI
/coder.c | 30 +-
+ 1 file changed, 17 insertions(+), 13 deletions(-)
+
+commit ec26f3ace5f9b260ca91508030f07465ae2f9f78
+Author: Lasse Collin 
+Date:   2020-01-26 14:13:42 +0200
+
+xz: Fix semi-busy-waiting in xz --flush-timeout.
+
+When input blocked, xz --flush-timeout=1 would wake up every
+millisecond and initiate flushing which would have nothing to
+flush and thus would just waste CPU time. The fix disables the
+timeout when no input has been seen since the previous flush.
+
+ src/xz/coder.c   |  4 
+ src/xz/file_io.c | 15 +++
+ src/xz/file_io.h |  4 
+ 3 files changed, 19 insertions(+), 4 deletions(-)
+
+commit 38915703241e69a64f133ff9a02ec9100c6019c6
+Author: Lasse Collin 
+Date:   2020-01-26 13:47:31 +0200
+
+xz: Refactor io_read() a bit.
+
+ src/xz/file_io.c | 17 -
+ 1 file changed, 8 insertions(+), 9 deletions(-)
+
+commit f6d24245349cecfae6ec0d2366fa80716c9f6d37
+Author: Lasse Collin 
+Date:   2020-01-26 13:37:08 +0200
+
+xz: Update a comment in file_io.h.
+
+ src/xz/file_io.h | 5 -
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+commit 15b55d5c63d27f81776edb1abc05872a751fc674
+Author: Lasse Collin 
+Date:   2020-01-26 13:27:51 +0200
+
+xz: Move the setting of flush_needed in file_io.c to a nicer location.
+
+ src/xz/file_io.c | 6 ++
+ 1 file changed, 2 insertions(+), 4 deletions(-)
+
+commit 609c7067859146ffc62ac655f6ba53599c891801
+Author: Lasse Collin 
+Date:   2020-02-05 19:56:09 +0200
+
+xz: Enable Capsicum sandboxing by default if available.
+
+It has been enabled in FreeBSD for a while and reported to work fine.
+
+Thanks to Xin Li.
+
+ INSTALL  | 6 --
+ configure.ac | 8 
+ 2 files changed, 4 insertions(+), 10 deletions(-)
+
+commit 00517d125cc26ecece0eebb84c1c3975cd19bee0
+Author: Lasse Collin 
+Date:   2019-12-31 22:41:45 +0200
+
+Rename unaligned_read32ne to read32ne, and similarly for the others.
+
+ src/common/tuklib_integer.h   | 64 +++
+ src/liblzma/common/alone_encoder.c|  2 +-
+ src/liblzma/common/block_header_decoder.c |  2 +-
+ src/liblzma/common/block_header_encoder.c |  2 +-
+ src/liblzma/common/memcmplen.h|  9 ++---
+ src/liblzma/common/stream_flags_decoder.c |  6 +--
+ src/liblzma/common/stream_flags_encoder.c |  8 ++--
+ src/liblzma/lz/lz_encoder_hash.h  |  2 +-
+ src/liblzma/lzma/lzma_decoder.c   |  2 +-
+ src/liblzma/lzma/lzma_encoder.c   |  2 +-
+ src/liblzma/lzma/lzma_encoder_private.h   |  3 +-
+ src/liblzma/simple/simple_decoder.c   |  2 +-
+ src/liblzma/simple/simple_encoder.c   |  2 +-
+ tests/test_block_header.c |  4 +-
+ tests/test_stream_flags.c |  6 +--
+ 15 files changed, 54 insertions(+), 62 deletions(-)
+
+commit 52d89d8443c4a31a69c0701062f2c7711d82bbed
+Author: Lasse Collin 
+Date:   2019-12-31 00:29:48 +0200
+
+Rename read32ne to aligned_read32ne, and similarly for the others.
+
+Using the aligned methods requires more care to ensure that
+the address really is aligned, so it's nicer if the aligned
+methods are prefixed. The next commit will remove the unaligned_
+prefix from the unaligned methods which in liblzma are used in
+more places than the aligned ones.
+
+ src/common/tuklib_integer.h| 56 +-
+ src/liblzma/check/crc32_fast.c |  4 +--
+ src/liblzma/check/crc64_fast.c |  4 +--
+ 3 files changed, 32 insertions(+), 32 deletions(-)
+
+commit 850620468b57d49f16093e5870d1050886fcb37a
+Author: Lasse Collin 
+Date:   2019-12-31 00:18:24 +0200
+
+Revise tuklib_integer.h and .m4.
+
+Add a configure option --enable-unsafe-type-punning to get the
+old non-conforming memory access methods. It can be useful with
+old compilers or in some other less typical situations but
+shouldn't normally be used.
+
+Omit the packed struct trick for unaligned access. While it's
+best in some cases, this is simpler. If the memcpy trick doesn't
+work, one can request unsafe type punning from configure.
+
+Because CRC32/CRC64 code needs fast aligned reads, if no very
+safe way to do it is found, type punning is used as a fallback.
+This sucks but since it currently works in practice, it seems to
+be the least bad option. It's never needed with GCC >= 4.7 or
+Clang >= 3.6 since these support __builtin_assume_aligned and
+thus fast aligned access can be done with the memcpy trick.
+
+Other things:
+  - Support GCC/Clang __builtin_bswapXX
+  - Cleaner bswap fallback macros
+  - Minor cleanups
+
+ m4/tuklib_integer.m4|  43 
+ src/common/tuklib_integer.h | 488 
+ 2 files changed, 314 insertions(+), 217 deletions(-)
+
+commit a45badf0342666462cc6a7107a071418570ab773
+Author:

svn commit: r359201 - in head: contrib/xz contrib/xz/src/common contrib/xz/src/liblzma/api contrib/xz/src/liblzma/api/lzma contrib/xz/src/liblzma/check contrib/xz/src/liblzma/common contrib/xz/src/...

2020-03-21 Thread Xin LI
ch would have nothing to
+flush and thus would just waste CPU time. The fix disables the
+timeout when no input has been seen since the previous flush.
+
+ src/xz/coder.c   |  4 
+ src/xz/file_io.c | 15 +++
+ src/xz/file_io.h |  4 
+ 3 files changed, 19 insertions(+), 4 deletions(-)
+
+commit 38915703241e69a64f133ff9a02ec9100c6019c6
+Author: Lasse Collin 
+Date:   2020-01-26 13:47:31 +0200
+
+xz: Refactor io_read() a bit.
+
+ src/xz/file_io.c | 17 -
+ 1 file changed, 8 insertions(+), 9 deletions(-)
+
+commit f6d24245349cecfae6ec0d2366fa80716c9f6d37
+Author: Lasse Collin 
+Date:   2020-01-26 13:37:08 +0200
+
+xz: Update a comment in file_io.h.
+
+ src/xz/file_io.h | 5 -
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+commit 15b55d5c63d27f81776edb1abc05872a751fc674
+Author: Lasse Collin 
+Date:   2020-01-26 13:27:51 +0200
+
+xz: Move the setting of flush_needed in file_io.c to a nicer location.
+
+ src/xz/file_io.c | 6 ++
+ 1 file changed, 2 insertions(+), 4 deletions(-)
+
+commit 609c7067859146ffc62ac655f6ba53599c891801
+Author: Lasse Collin 
+Date:   2020-02-05 19:56:09 +0200
+
+xz: Enable Capsicum sandboxing by default if available.
+
+It has been enabled in FreeBSD for a while and reported to work fine.
+
+Thanks to Xin Li.
+
+ INSTALL  | 6 --
+ configure.ac | 8 
+ 2 files changed, 4 insertions(+), 10 deletions(-)
+
+commit 00517d125cc26ecece0eebb84c1c3975cd19bee0
+Author: Lasse Collin 
+Date:   2019-12-31 22:41:45 +0200
+
+Rename unaligned_read32ne to read32ne, and similarly for the others.
+
+ src/common/tuklib_integer.h   | 64 +++
+ src/liblzma/common/alone_encoder.c|  2 +-
+ src/liblzma/common/block_header_decoder.c |  2 +-
+ src/liblzma/common/block_header_encoder.c |  2 +-
+ src/liblzma/common/memcmplen.h|  9 ++---
+ src/liblzma/common/stream_flags_decoder.c |  6 +--
+ src/liblzma/common/stream_flags_encoder.c |  8 ++--
+ src/liblzma/lz/lz_encoder_hash.h  |  2 +-
+ src/liblzma/lzma/lzma_decoder.c   |  2 +-
+ src/liblzma/lzma/lzma_encoder.c   |  2 +-
+ src/liblzma/lzma/lzma_encoder_private.h   |  3 +-
+ src/liblzma/simple/simple_decoder.c   |  2 +-
+ src/liblzma/simple/simple_encoder.c   |  2 +-
+ tests/test_block_header.c |  4 +-
+ tests/test_stream_flags.c |  6 +--
+ 15 files changed, 54 insertions(+), 62 deletions(-)
+
+commit 52d89d8443c4a31a69c0701062f2c7711d82bbed
+Author: Lasse Collin 
+Date:   2019-12-31 00:29:48 +0200
+
+Rename read32ne to aligned_read32ne, and similarly for the others.
+
+Using the aligned methods requires more care to ensure that
+the address really is aligned, so it's nicer if the aligned
+methods are prefixed. The next commit will remove the unaligned_
+prefix from the unaligned methods which in liblzma are used in
+more places than the aligned ones.
+
+ src/common/tuklib_integer.h| 56 +-
+ src/liblzma/check/crc32_fast.c |  4 +--
+ src/liblzma/check/crc64_fast.c |  4 +--
+ 3 files changed, 32 insertions(+), 32 deletions(-)
+
+commit 850620468b57d49f16093e5870d1050886fcb37a
+Author: Lasse Collin 
+Date:   2019-12-31 00:18:24 +0200
+
+Revise tuklib_integer.h and .m4.
+
+Add a configure option --enable-unsafe-type-punning to get the
+old non-conforming memory access methods. It can be useful with
+old compilers or in some other less typical situations but
+shouldn't normally be used.
+
+Omit the packed struct trick for unaligned access. While it's
+best in some cases, this is simpler. If the memcpy trick doesn't
+work, one can request unsafe type punning from configure.
+
+Because CRC32/CRC64 code needs fast aligned reads, if no very
+safe way to do it is found, type punning is used as a fallback.
+This sucks but since it currently works in practice, it seems to
+be the least bad option. It's never needed with GCC >= 4.7 or
+Clang >= 3.6 since these support __builtin_assume_aligned and
+thus fast aligned access can be done with the memcpy trick.
+
+Other things:
+  - Support GCC/Clang __builtin_bswapXX
+  - Cleaner bswap fallback macros
+  - Minor cleanups
+
+ m4/tuklib_integer.m4|  43 
+ src/common/tuklib_integer.h | 488 
+ 2 files changed, 314 insertions(+), 217 deletions(-)
+
+commit a45badf0342666462cc6a7107a071418570ab773
+Author: Lasse Collin 
+Date:   2019-12-29 22:51:58 +0200
+
+Tests: Hopefully fix test_check.c to work on EBCDIC systems.
+
+Thanks to Daniel Richard G.
+
+ tests/test_check.c | 9 +++--
+ 1 file changed, 7 insertions(+), 2 deletions(-)
+
+commit c9a8071e6690a8db8a485c075920df254e7c70ea
+Author: Lasse Collin 
+Date:   2019-09-24 23:02:40 +0300
+
+Scripts:

svn commit: r359200 - vendor/xz/5.2.5

2020-03-21 Thread Xin LI
Author: delphij
Date: Sun Mar 22 01:25:50 2020
New Revision: 359200
URL: https://svnweb.freebsd.org/changeset/base/359200

Log:
  Tag xz 5.2.5.

Added:
  vendor/xz/5.2.5/
 - copied from r359199, vendor/xz/dist/
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r359197 - in vendor/xz/dist: . src/common src/liblzma/api src/liblzma/api/lzma src/liblzma/check src/liblzma/common src/liblzma/delta src/liblzma/lz src/liblzma/lzma src/liblzma/simple ...

2020-03-21 Thread Xin LI
+
+ src/xz/file_io.h |  4 
+ 3 files changed, 19 insertions(+), 4 deletions(-)
+
+commit 38915703241e69a64f133ff9a02ec9100c6019c6
+Author: Lasse Collin 
+Date:   2020-01-26 13:47:31 +0200
+
+xz: Refactor io_read() a bit.
+
+ src/xz/file_io.c | 17 -
+ 1 file changed, 8 insertions(+), 9 deletions(-)
+
+commit f6d24245349cecfae6ec0d2366fa80716c9f6d37
+Author: Lasse Collin 
+Date:   2020-01-26 13:37:08 +0200
+
+xz: Update a comment in file_io.h.
+
+ src/xz/file_io.h | 5 -
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+commit 15b55d5c63d27f81776edb1abc05872a751fc674
+Author: Lasse Collin 
+Date:   2020-01-26 13:27:51 +0200
+
+xz: Move the setting of flush_needed in file_io.c to a nicer location.
+
+ src/xz/file_io.c | 6 ++
+ 1 file changed, 2 insertions(+), 4 deletions(-)
+
+commit 609c7067859146ffc62ac655f6ba53599c891801
+Author: Lasse Collin 
+Date:   2020-02-05 19:56:09 +0200
+
+xz: Enable Capsicum sandboxing by default if available.
+
+It has been enabled in FreeBSD for a while and reported to work fine.
+
+Thanks to Xin Li.
+
+ INSTALL  | 6 --
+ configure.ac | 8 
+ 2 files changed, 4 insertions(+), 10 deletions(-)
+
+commit 00517d125cc26ecece0eebb84c1c3975cd19bee0
+Author: Lasse Collin 
+Date:   2019-12-31 22:41:45 +0200
+
+Rename unaligned_read32ne to read32ne, and similarly for the others.
+
+ src/common/tuklib_integer.h   | 64 +++
+ src/liblzma/common/alone_encoder.c|  2 +-
+ src/liblzma/common/block_header_decoder.c |  2 +-
+ src/liblzma/common/block_header_encoder.c |  2 +-
+ src/liblzma/common/memcmplen.h|  9 ++---
+ src/liblzma/common/stream_flags_decoder.c |  6 +--
+ src/liblzma/common/stream_flags_encoder.c |  8 ++--
+ src/liblzma/lz/lz_encoder_hash.h  |  2 +-
+ src/liblzma/lzma/lzma_decoder.c   |  2 +-
+ src/liblzma/lzma/lzma_encoder.c   |  2 +-
+ src/liblzma/lzma/lzma_encoder_private.h   |  3 +-
+ src/liblzma/simple/simple_decoder.c   |  2 +-
+ src/liblzma/simple/simple_encoder.c   |  2 +-
+ tests/test_block_header.c |  4 +-
+ tests/test_stream_flags.c |  6 +--
+ 15 files changed, 54 insertions(+), 62 deletions(-)
+
+commit 52d89d8443c4a31a69c0701062f2c7711d82bbed
+Author: Lasse Collin 
+Date:   2019-12-31 00:29:48 +0200
+
+Rename read32ne to aligned_read32ne, and similarly for the others.
+
+Using the aligned methods requires more care to ensure that
+the address really is aligned, so it's nicer if the aligned
+methods are prefixed. The next commit will remove the unaligned_
+prefix from the unaligned methods which in liblzma are used in
+more places than the aligned ones.
+
+ src/common/tuklib_integer.h| 56 +-
+ src/liblzma/check/crc32_fast.c |  4 +--
+ src/liblzma/check/crc64_fast.c |  4 +--
+ 3 files changed, 32 insertions(+), 32 deletions(-)
+
+commit 850620468b57d49f16093e5870d1050886fcb37a
+Author: Lasse Collin 
+Date:   2019-12-31 00:18:24 +0200
+
+Revise tuklib_integer.h and .m4.
+
+Add a configure option --enable-unsafe-type-punning to get the
+old non-conforming memory access methods. It can be useful with
+old compilers or in some other less typical situations but
+shouldn't normally be used.
+
+Omit the packed struct trick for unaligned access. While it's
+best in some cases, this is simpler. If the memcpy trick doesn't
+work, one can request unsafe type punning from configure.
+
+Because CRC32/CRC64 code needs fast aligned reads, if no very
+safe way to do it is found, type punning is used as a fallback.
+This sucks but since it currently works in practice, it seems to
+be the least bad option. It's never needed with GCC >= 4.7 or
+Clang >= 3.6 since these support __builtin_assume_aligned and
+thus fast aligned access can be done with the memcpy trick.
+
+Other things:
+  - Support GCC/Clang __builtin_bswapXX
+  - Cleaner bswap fallback macros
+  - Minor cleanups
+
+ m4/tuklib_integer.m4|  43 
+ src/common/tuklib_integer.h | 488 
+ 2 files changed, 314 insertions(+), 217 deletions(-)
+
+commit a45badf0342666462cc6a7107a071418570ab773
+Author: Lasse Collin 
+Date:   2019-12-29 22:51:58 +0200
+
+Tests: Hopefully fix test_check.c to work on EBCDIC systems.
+
+Thanks to Daniel Richard G.
+
+ tests/test_check.c | 9 +++--
+ 1 file changed, 7 insertions(+), 2 deletions(-)
+
+commit c9a8071e6690a8db8a485c075920df254e7c70ea
+Author: Lasse Collin 
+Date:   2019-09-24 23:02:40 +0300
+
+Scripts: Put /usr/xpg4/bin to the beginning of PATH on Solaris.
+
+This adds a configure option --enable-path-for-scripts=PREFIX
+which defaults to empty except on Solaris it is /usr/xpg4/bin
+to make POSIX grep an

svn commit: r359118 - head/lib/libc/nls

2020-03-18 Thread Xin LI
Author: delphij
Date: Thu Mar 19 06:33:06 2020
New Revision: 359118
URL: https://svnweb.freebsd.org/changeset/base/359118

Log:
  Fix race condition in catopen(3).
  
  The current code uses a rwlock to protect the cached list, which
  in turn holds a list of catentry objects, and increments reference
  count while holding only read lock.
  
  Fix this by converting the reference counter to use atomic operations.
  
  While I'm there, also perform some clean ups around memory operations.
  
  PR:   202636
  Reported by:  Henry Hu 
  Reviewed by:  markj
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D24095

Modified:
  head/lib/libc/nls/msgcat.c

Modified: head/lib/libc/nls/msgcat.c
==
--- head/lib/libc/nls/msgcat.c  Thu Mar 19 03:37:02 2020(r359117)
+++ head/lib/libc/nls/msgcat.c  Thu Mar 19 06:33:06 2020(r359118)
@@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #include  /* for ntohl() */
+#include 
 
 #include 
 #include 
@@ -76,19 +77,25 @@ __FBSDID("$FreeBSD$");
 
 #defineNLERR   ((nl_catd) -1)
 #define NLRETERR(errc)  { errno = errc; return (NLERR); }
-#define SAVEFAIL(n, l, e)  { WLOCK(NLERR); 
\
- np = malloc(sizeof(struct catentry)); 
\
+#define SAVEFAIL(n, l, e)  { np = calloc(1, sizeof(struct catentry));  
\
  if (np != NULL) { 
\
np->name = strdup(n);   
\
-   np->path = NULL;
\
np->catd = NLERR;   
\
-   np->refcount = 0;   
\
np->lang = (l == NULL) ? NULL : 
\
strdup(l);  
\
np->caterrno = e;   
\
-   SLIST_INSERT_HEAD(&cache, np, list);
\
+   if (np->name == NULL || 
\
+   (l != NULL && np->lang == NULL)) {  
\
+   free(np->name); 
\
+   free(np->lang); 
\
+   free(np);   
\
+   } else {
\
+   WLOCK(NLERR);   
\
+   SLIST_INSERT_HEAD(&cache, np,   
\
+   list);  
\
+   UNLOCK; 
\
+   }   
\
  } 
\
- UNLOCK;   
\
  errno = e;
\
}
 
@@ -152,7 +159,7 @@ catopen(const char *name, int type)
NLRETERR(np->caterrno);
} else {
/* Found cached successful entry */
-   np->refcount++;
+   atomic_add_int(&np->refcount, 1);
UNLOCK;
return (np->catd);
}
@@ -355,8 +362,7 @@ catclose(nl_catd catd)
WLOCK(-1);
SLIST_FOREACH(np, &cache, list) {
if (catd == np->catd) {
-   np->refcount--;
-   if (np->refcount == 0)
+   if (atomic_fetchadd_int(&np->refcount, -1) == 1)
catfree(np);
break;
}
@@ -376,6 +382,7 @@ load_msgcat(const char *path, const char *name, const 
nl_catd catd;
struct catentry *np;
void *data;
+   char *copy_path, *copy_name, *copy_lang;
int fd;
 
/* path/name will never be NULL here */
@@ -387,7 +394,7 @@ load_msgcat(const char *path, const char *name, const 
RLOCK(NLERR);
SLIST_FOREACH(np, &cache, list) {
if ((np->path != NULL) && (strcmp(np->path, path) == 0)) {
-   np->refcount++;
+   atomic_add_int(&np->refcount, 1);
UNLOCK;
return (np->catd);
}
@@ -432,7 +439,20 @@ load_msgcat(const char *path, const 

svn commit: r358988 - head/usr.bin/gzip

2020-03-13 Thread Xin LI
Author: delphij
Date: Sat Mar 14 05:57:22 2020
New Revision: 358988
URL: https://svnweb.freebsd.org/changeset/base/358988

Log:
  Remove unneeded checks for prelen.
  
  In order to determine the type of a compressed file, we have to read
  in the first four bytes which may also be important for decompression
  purposes, to do that we would pass the buffer that we have already
  read in, along with the size of it.
  
  Rename header1 to fourbytes to make that explicit, and remove all
  checks for prelen.
  
  Reported by:  cem
  Reviewed by:  cem
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D24034

Modified:
  head/usr.bin/gzip/gzip.c
  head/usr.bin/gzip/unlz.c
  head/usr.bin/gzip/unpack.c

Modified: head/usr.bin/gzip/gzip.c
==
--- head/usr.bin/gzip/gzip.cSat Mar 14 02:36:45 2020(r358987)
+++ head/usr.bin/gzip/gzip.cSat Mar 14 05:57:22 2020(r358988)
@@ -1443,7 +1443,7 @@ file_uncompress(char *file, char *outfile, size_t outs
struct stat isb, osb;
off_t size;
ssize_t rbytes;
-   unsigned char header1[4];
+   unsigned char fourbytes[4];
enum filetype method;
int fd, ofd, zfd = -1;
int error;
@@ -1477,8 +1477,8 @@ file_uncompress(char *file, char *outfile, size_t outs
goto lose;
}
 
-   rbytes = read(fd, header1, sizeof header1);
-   if (rbytes != sizeof header1) {
+   rbytes = read(fd, fourbytes, sizeof fourbytes);
+   if (rbytes != sizeof fourbytes) {
/* we don't want to fail here. */
 #ifndef SMALL
if (fflag)
@@ -1492,7 +1492,7 @@ file_uncompress(char *file, char *outfile, size_t outs
}
infile_newdata(rbytes);
 
-   method = file_gettype(header1);
+   method = file_gettype(fourbytes);
 #ifndef SMALL
if (fflag == 0 && method == FT_UNKNOWN) {
maybe_warnx("%s: not in gzip format", file);
@@ -1516,7 +1516,7 @@ file_uncompress(char *file, char *outfile, size_t outs
infile_newdata(rv);
timestamp = le32dec(&ts[0]);
 
-   if (header1[3] & ORIG_NAME) {
+   if (fourbytes[3] & ORIG_NAME) {
rbytes = pread(fd, name, sizeof(name) - 1, 
GZIP_ORIGNAME);
if (rbytes < 0) {
maybe_warn("can't read %s", file);
@@ -1818,7 +1818,7 @@ static void
 handle_stdin(void)
 {
struct stat isb;
-   unsigned char header1[4];
+   unsigned char fourbytes[4];
size_t in_size;
off_t usize, gsize;
enum filetype method;
@@ -1849,16 +1849,16 @@ handle_stdin(void)
goto out;
}
 
-   bytes_read = read_retry(STDIN_FILENO, header1, sizeof header1);
+   bytes_read = read_retry(STDIN_FILENO, fourbytes, sizeof fourbytes);
if (bytes_read == -1) {
maybe_warn("can't read stdin");
goto out;
-   } else if (bytes_read != sizeof(header1)) {
+   } else if (bytes_read != sizeof(fourbytes)) {
maybe_warnx("(stdin): unexpected end of file");
goto out;
}
 
-   method = file_gettype(header1);
+   method = file_gettype(fourbytes);
switch (method) {
default:
 #ifndef SMALL
@@ -1866,17 +1866,17 @@ handle_stdin(void)
maybe_warnx("unknown compression format");
goto out;
}
-   usize = cat_fd(header1, sizeof header1, &gsize, STDIN_FILENO);
+   usize = cat_fd(fourbytes, sizeof fourbytes, &gsize, 
STDIN_FILENO);
break;
 #endif
case FT_GZIP:
usize = gz_uncompress(STDIN_FILENO, STDOUT_FILENO,
- (char *)header1, sizeof header1, &gsize, 
"(stdin)");
+ (char *)fourbytes, sizeof fourbytes, &gsize, 
"(stdin)");
break;
 #ifndef NO_BZIP2_SUPPORT
case FT_BZIP2:
usize = unbzip2(STDIN_FILENO, STDOUT_FILENO,
-   (char *)header1, sizeof header1, &gsize);
+   (char *)fourbytes, sizeof fourbytes, &gsize);
break;
 #endif
 #ifndef NO_COMPRESS_SUPPORT
@@ -1886,27 +1886,27 @@ handle_stdin(void)
goto out;
}
 
-   usize = zuncompress(in, stdout, (char *)header1,
-   sizeof header1, &gsize);
+   usize = zuncompress(in, stdout, (char *)fourbytes,
+   sizeof fourbytes, &gsize);
fclose(in);
break;
 #endif
 #ifndef NO_PACK_SUPPORT
case FT_PACK:
usize = unpack(STDIN_FILENO, STDOUT_FILENO,
-  (char *)header1, sizeof header1, &gsize);
+  (char *)fourbytes, sizeof fourbytes, &gsize);
   

Re: svn commit: r326052 - head/usr.bin/gzip

2020-03-11 Thread Xin Li
On 3/10/20 18:26, Conrad Meyer wrote:
> Hi Xin Li,
> 
> Sorry to reply to an old commit.
> 
> On Tue, Nov 21, 2017 at 12:14 AM Xin LI  wrote:
>>
>> Author: delphij
>> Date: Tue Nov 21 08:14:30 2017
>> New Revision: 326052
>> URL: https://svnweb.freebsd.org/changeset/base/326052
>>
>> Log:
>>   Support SIGINFO.
>> ...
>> --- head/usr.bin/gzip/unpack.c  Tue Nov 21 07:35:29 2017(r326051)
>> +++ head/usr.bin/gzip/unpack.c  Tue Nov 21 08:14:30 2017(r326052)
>> ...
>> @@ -152,6 +155,9 @@ unpack_parse_header(int in, int out, char *pre, size_t
>> ssize_t bytesread;  /* Bytes read from the file */
>> int i, j, thisbyte;
>>
>> +   if (prelen > sizeof hdr)
>> +   maybe_err("prelen too long");
> 
> This check should perhaps be >=, rather than >.
> 
>> +
>> /* Prepend the header buffer if we already read some data */
>> if (prelen != 0)
>> memcpy(hdr, pre, prelen);
>> @@ -160,6 +166,7 @@ unpack_parse_header(int in, int out, char *pre, size_t
>> bytesread = read(in, hdr + prelen, PACK_HEADER_LENGTH - prelen);
> 
> In the case where prelen == sizeof(hdr), we invoke read(, pointer past
> end of hdr, 0) above.  This should have no effect, but looks
> unintended, and tickles Coverity (CID 1383554).

Thanks for the analysis.  It seems that this is a false positive because
the situation can never happen with the current code (the passed prelen
has to be either 0 or 4).

I've created a changeset at: https://reviews.freebsd.org/D24034 to
address it.

Cheers,





signature.asc
Description: OpenPGP digital signature


svn commit: r358496 - head/sys/dev/iscsi_initiator

2020-03-01 Thread Xin LI
Author: delphij
Date: Sun Mar  1 18:55:59 2020
New Revision: 358496
URL: https://svnweb.freebsd.org/changeset/base/358496

Log:
  Fix build.

Modified:
  head/sys/dev/iscsi_initiator/isc_sm.c
  head/sys/dev/iscsi_initiator/iscsi_subr.c

Modified: head/sys/dev/iscsi_initiator/isc_sm.c
==
--- head/sys/dev/iscsi_initiator/isc_sm.c   Sun Mar  1 18:18:11 2020
(r358495)
+++ head/sys/dev/iscsi_initiator/isc_sm.c   Sun Mar  1 18:55:59 2020
(r358496)
@@ -514,7 +514,7 @@ proc_out(isc_session_t *sp)
if(pq->ccb) {
 xdebug("back to cam");
 pq->ccb->ccb_h.status |= CAM_REQUEUE_REQ; // some 
better error?
-xpt_done(sp, pq->ccb);
+xpt_done(pq->ccb);
 pdu_free(sp->isc, pq);
}
else
@@ -747,4 +747,4 @@ ism_start(isc_session_t *sp)
  debug(4, "starting ism_proc: sp->sid=%d", sp->sid);
 
  return kproc_create(ism_out, sp, &sp->stp, 0, 0, "isc_out %d", sp->sid);
-a}
+}

Modified: head/sys/dev/iscsi_initiator/iscsi_subr.c
==
--- head/sys/dev/iscsi_initiator/iscsi_subr.c   Sun Mar  1 18:18:11 2020
(r358495)
+++ head/sys/dev/iscsi_initiator/iscsi_subr.c   Sun Mar  1 18:55:59 2020
(r358496)
@@ -248,7 +248,7 @@ _scsi_done(isc_session_t *sp, u_int response, u_int st
  }
  sdebug(5, "ccb_h->status=%x", ccb_h->status);
 
- xpt_done(sp, ccb);
+ xpt_done(ccb);
 }
 
 /*
@@ -408,7 +408,7 @@ iscsi_reject(isc_session_t *sp, pduq_t *opq, pduq_t *p
  debug_called(8);
  //XXX: check RFC 10.17.1 (page 176)
  ccb->ccb_h.status = CAM_REQ_ABORTED;
- xpt_done(sp, ccb);
+ xpt_done(ccb);
  
  pdu_free(sp->isc, opq);
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r358155 - head/share/man/man4

2020-02-19 Thread Xin LI
Author: delphij
Date: Thu Feb 20 06:45:51 2020
New Revision: 358155
URL: https://svnweb.freebsd.org/changeset/base/358155

Log:
  Actually install hwpstate_intel.4.

Modified:
  head/share/man/man4/Makefile

Modified: head/share/man/man4/Makefile
==
--- head/share/man/man4/MakefileThu Feb 20 06:03:41 2020
(r358154)
+++ head/share/man/man4/MakefileThu Feb 20 06:45:51 2020
(r358155)
@@ -192,6 +192,7 @@ MAN=aac.4 \
${_hv_vmbus.4} \
${_hv_vss.4} \
hwpmc.4 \
+   ${_hwpstate_intel.4} \
iavf.4 \
ichsmb.4 \
${_ichwd.4} \
@@ -787,6 +788,7 @@ _hv_storvsc.4=  hv_storvsc.4
 _hv_utils.4=   hv_utils.4
 _hv_vmbus.4=   hv_vmbus.4
 _hv_vss.4= hv_vss.4
+_hwpstate_intel.4= hwpstate_intel.4
 _i8254.4=  i8254.4
 _ichwd.4=  ichwd.4
 _if_bxe.4= if_bxe.4
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r358153 - head/usr.sbin/services_mkdb

2020-02-19 Thread Xin Li via svn-src-all


On 2/19/20 10:01 PM, Yuri Pankov wrote:
> On 20 Feb 2020, at 06:54, Pedro F. Giffuni  wrote:
>>
>> Author: pfg
>> Date: Thu Feb 20 03:54:07 2020
>> New Revision: 358153
>> URL: https://svnweb.freebsd.org/changeset/base/358153
>>
>> Log:
>>  /etc/services: attempt bring the database to this century.
>>
>>  Document better this file, updating the URL to the IANA registry and closely
>>  match the official services.
>>
>>  For system ports (0 to 1023) we now try to follow the registry closely, 
>> noting
>>  some historical differences where applicable.
>>  For the User ports (1024 - 49151) we try to keep some sensible balance only
>>  of services that are likely to be found on FreeBSD/UNIX systems. This 
>> attempts
>>  to strike a balance between complexity and usefulness.
>>
>>  As a side effect: drop references to unofficial Kerberos IV which was EOL'ed
>>  on Oct 2006[1]. While it is conceivable some people may still use it in some
>>  very old FreeBSD machines that can't be replaced easily, the use of it is
>>  considered a security risk. Also drop the unofficial netatalk, which we
>>  supported long ago in the kernel but was dropped long ago.
>>
>>  [1] https://web.mit.edu/kerberos/krb4-end-of-life.html
>>
>>  MFC after:  3 weeks (likely to 12-stable only)
>>  Differential Revision:  https://reviews.freebsd.org/D23621
>>
>> Modified:
>>  head/usr.sbin/services_mkdb/services
> 
> I noticed `mergemaster` failing, and it seems to be not happy with this 
> change:
> 
> # make installconfig
> installing DIRS CONFSDIR
> install  -d -m 0755 -o root  -g wheel  /etc
> install  -C -o root  -g wheel -m 644  
> /usr/src/usr.sbin/services_mkdb/services /etc/services
> services_mkdb -l -q -o /var/db/services.db  /etc/services
> services_mkdb: Ran out of protocols adding `divert'; recompile with larger 
> PROTOMAX
> *** Error code 1
> 
> Stop.
> make: stopped in /usr/src/usr.sbin/services_mkdb

Fixed in r358154.  Please merge the revision with r358153 when MFC'ing.



signature.asc
Description: OpenPGP digital signature


svn commit: r358154 - head/usr.sbin/services_mkdb

2020-02-19 Thread Xin LI
Author: delphij
Date: Thu Feb 20 06:03:41 2020
New Revision: 358154
URL: https://svnweb.freebsd.org/changeset/base/358154

Log:
  Bump PROTOMAX.
  
  MFC after:3 weeks
  X-MFC-with:   r358153

Modified:
  head/usr.sbin/services_mkdb/services_mkdb.c

Modified: head/usr.sbin/services_mkdb/services_mkdb.c
==
--- head/usr.sbin/services_mkdb/services_mkdb.c Thu Feb 20 03:54:07 2020
(r358153)
+++ head/usr.sbin/services_mkdb/services_mkdb.c Thu Feb 20 06:03:41 2020
(r358154)
@@ -56,7 +56,7 @@ __FBSDID("$FreeBSD$");
 static char tname[MAXPATHLEN];
 
 #definePMASK   0x
-#define PROTOMAX   5
+#define PROTOMAX   6
 
 static voidadd(DB *, StringList *, size_t, const char *, size_t *, int);
 static StringList ***parseservices(const char *, StringList *);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r357993 - in stable/12/sbin: fsck fsck_ffs

2020-02-15 Thread Xin LI
Author: delphij
Date: Sun Feb 16 07:06:25 2020
New Revision: 357993
URL: https://svnweb.freebsd.org/changeset/base/357993

Log:
  MFC r356000: Remove unused includes.

Modified:
  stable/12/sbin/fsck/fsck.c
  stable/12/sbin/fsck/fsutil.c
  stable/12/sbin/fsck_ffs/utilities.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sbin/fsck/fsck.c
==
--- stable/12/sbin/fsck/fsck.c  Sun Feb 16 06:34:45 2020(r357992)
+++ stable/12/sbin/fsck/fsck.c  Sun Feb 16 07:06:25 2020(r357993)
@@ -48,7 +48,6 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 

Modified: stable/12/sbin/fsck/fsutil.c
==
--- stable/12/sbin/fsck/fsutil.cSun Feb 16 06:34:45 2020
(r357992)
+++ stable/12/sbin/fsck/fsutil.cSun Feb 16 07:06:25 2020
(r357993)
@@ -42,8 +42,6 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #include 
-#include 
-#include 
 #include 
 #include 
 #include 

Modified: stable/12/sbin/fsck_ffs/utilities.c
==
--- stable/12/sbin/fsck_ffs/utilities.c Sun Feb 16 06:34:45 2020
(r357992)
+++ stable/12/sbin/fsck_ffs/utilities.c Sun Feb 16 07:06:25 2020
(r357993)
@@ -45,15 +45,11 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
-#include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
-#include 
-#include 
 
 #include "fsck.h"
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r357992 - stable/12/bin/pwait

2020-02-15 Thread Xin LI
Author: delphij
Date: Sun Feb 16 06:34:45 2020
New Revision: 357992
URL: https://svnweb.freebsd.org/changeset/base/357992

Log:
  MFC r357420: Remove unused include.

Modified:
  stable/12/bin/pwait/pwait.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/bin/pwait/pwait.c
==
--- stable/12/bin/pwait/pwait.c Sun Feb 16 03:33:34 2020(r357991)
+++ stable/12/bin/pwait/pwait.c Sun Feb 16 06:34:45 2020(r357992)
@@ -41,7 +41,6 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r357757 - in head: contrib/file contrib/file/doc contrib/file/m4 contrib/file/magic contrib/file/magic/Magdir contrib/file/python contrib/file/src contrib/file/tests lib/libmagic

2020-02-10 Thread Xin LI
Author: delphij
Date: Tue Feb 11 07:02:48 2020
New Revision: 357757
URL: https://svnweb.freebsd.org/changeset/base/357757

Log:
  MFV r357712: file 5.38.
  
  MFC after:2 weeks

Added:
  head/contrib/file/magic/Magdir/forth
 - copied unchanged from r357712, vendor/file/dist/magic/Magdir/forth
  head/contrib/file/magic/Magdir/git
 - copied unchanged from r357712, vendor/file/dist/magic/Magdir/git
  head/contrib/file/magic/Magdir/modulefile
 - copied unchanged from r357712, vendor/file/dist/magic/Magdir/modulefile
  head/contrib/file/magic/Magdir/openfst
 - copied unchanged from r357712, vendor/file/dist/magic/Magdir/openfst
  head/contrib/file/magic/Magdir/opentimestamps
 - copied unchanged from r357712, 
vendor/file/dist/magic/Magdir/opentimestamps
  head/contrib/file/magic/Magdir/pmem
 - copied unchanged from r357712, vendor/file/dist/magic/Magdir/pmem
  head/contrib/file/magic/Magdir/rst
 - copied unchanged from r357712, vendor/file/dist/magic/Magdir/rst
  head/contrib/file/magic/Magdir/sosi
 - copied unchanged from r357712, vendor/file/dist/magic/Magdir/sosi
  head/contrib/file/src/is_csv.c
 - copied unchanged from r357712, vendor/file/dist/src/is_csv.c
Modified:
  head/contrib/file/ChangeLog
  head/contrib/file/Makefile.in
  head/contrib/file/README
  head/contrib/file/aclocal.m4
  head/contrib/file/compile
  head/contrib/file/config.guess
  head/contrib/file/config.h.in
  head/contrib/file/config.sub
  head/contrib/file/configure
  head/contrib/file/configure.ac
  head/contrib/file/depcomp
  head/contrib/file/doc/Makefile.in
  head/contrib/file/doc/file.man
  head/contrib/file/doc/libmagic.man
  head/contrib/file/doc/magic.man
  head/contrib/file/ltmain.sh
  head/contrib/file/m4/libtool.m4
  head/contrib/file/m4/ltoptions.m4
  head/contrib/file/m4/ltsugar.m4
  head/contrib/file/m4/ltversion.m4
  head/contrib/file/m4/lt~obsolete.m4
  head/contrib/file/magic/Magdir/android
  head/contrib/file/magic/Magdir/animation
  head/contrib/file/magic/Magdir/apple
  head/contrib/file/magic/Magdir/archive
  head/contrib/file/magic/Magdir/audio
  head/contrib/file/magic/Magdir/bsi
  head/contrib/file/magic/Magdir/c-lang
  head/contrib/file/magic/Magdir/cad
  head/contrib/file/magic/Magdir/commands
  head/contrib/file/magic/Magdir/compress
  head/contrib/file/magic/Magdir/console
  head/contrib/file/magic/Magdir/database
  head/contrib/file/magic/Magdir/elf
  head/contrib/file/magic/Magdir/espressif
  head/contrib/file/magic/Magdir/filesystems
  head/contrib/file/magic/Magdir/fonts
  head/contrib/file/magic/Magdir/frame
  head/contrib/file/magic/Magdir/games
  head/contrib/file/magic/Magdir/gimp
  head/contrib/file/magic/Magdir/icc
  head/contrib/file/magic/Magdir/images
  head/contrib/file/magic/Magdir/javascript
  head/contrib/file/magic/Magdir/kml
  head/contrib/file/magic/Magdir/linux
  head/contrib/file/magic/Magdir/macintosh
  head/contrib/file/magic/Magdir/mail.news
  head/contrib/file/magic/Magdir/map
  head/contrib/file/magic/Magdir/msdos
  head/contrib/file/magic/Magdir/msooxml
  head/contrib/file/magic/Magdir/ole2compounddocs
  head/contrib/file/magic/Magdir/pdf
  head/contrib/file/magic/Magdir/python
  head/contrib/file/magic/Magdir/rpi
  head/contrib/file/magic/Magdir/ruby
  head/contrib/file/magic/Magdir/sgml
  head/contrib/file/magic/Magdir/sniffer
  head/contrib/file/magic/Magdir/ssh
  head/contrib/file/magic/Magdir/uuencode
  head/contrib/file/magic/Magdir/varied.script
  head/contrib/file/magic/Magdir/vax
  head/contrib/file/magic/Magdir/windows
  head/contrib/file/magic/Magdir/wordprocessors
  head/contrib/file/magic/Magdir/zip
  head/contrib/file/magic/Makefile.am
  head/contrib/file/magic/Makefile.in
  head/contrib/file/missing
  head/contrib/file/python/Makefile.in
  head/contrib/file/src/Makefile.am
  head/contrib/file/src/Makefile.in
  head/contrib/file/src/apprentice.c
  head/contrib/file/src/ascmagic.c
  head/contrib/file/src/buffer.c
  head/contrib/file/src/compress.c
  head/contrib/file/src/encoding.c
  head/contrib/file/src/file.c
  head/contrib/file/src/file.h
  head/contrib/file/src/file_opts.h
  head/contrib/file/src/fsmagic.c
  head/contrib/file/src/funcs.c
  head/contrib/file/src/magic.h.in
  head/contrib/file/src/readcdf.c
  head/contrib/file/src/readelf.c
  head/contrib/file/src/seccomp.c
  head/contrib/file/src/vasprintf.c
  head/contrib/file/tests/JW07022A.mp3.result
  head/contrib/file/tests/Makefile.in
  head/contrib/file/tests/test.c
  head/lib/libmagic/Makefile
  head/lib/libmagic/config.h
Directory Properties:
  head/contrib/file/   (props changed)

Modified: head/contrib/file/ChangeLog
==
--- head/contrib/file/ChangeLog Tue Feb 11 06:12:02 2020(r357756)
+++ head/contrib/file/ChangeLog Tue Feb 11 07:02:48 2020(r357757)
@@ -1,3 +1,23 @@
+2019-12-16  21:11  Christos Zoulas 
+
+   * release 5.38
+
+2019-12-15  22:13  Christos Zoulas 
+Docum

svn commit: r357716 - head/sbin/fsck_msdosfs

2020-02-09 Thread Xin LI
Author: delphij
Date: Mon Feb 10 04:16:41 2020
New Revision: 357716
URL: https://svnweb.freebsd.org/changeset/base/357716

Log:
  Use humanize_number to format available and bad space sizes.
  
  Reviewed by:  mckusick (earlier version)
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D23050

Modified:
  head/sbin/fsck_msdosfs/Makefile
  head/sbin/fsck_msdosfs/check.c

Modified: head/sbin/fsck_msdosfs/Makefile
==
--- head/sbin/fsck_msdosfs/Makefile Mon Feb 10 02:44:29 2020
(r357715)
+++ head/sbin/fsck_msdosfs/Makefile Mon Feb 10 04:16:41 2020
(r357716)
@@ -9,6 +9,7 @@ PROG=   fsck_msdosfs
 MAN=   fsck_msdosfs.8
 SRCS=  main.c check.c boot.c fat.c dir.c fsutil.c
 
-CFLAGS+= -I${FSCK}
+CFLAGS+= -I${FSCK} -DHAVE_LIBUTIL_H
+LIBADD=util
 
 .include 

Modified: head/sbin/fsck_msdosfs/check.c
==
--- head/sbin/fsck_msdosfs/check.c  Mon Feb 10 02:44:29 2020
(r357715)
+++ head/sbin/fsck_msdosfs/check.c  Mon Feb 10 04:16:41 2020
(r357716)
@@ -33,6 +33,9 @@ static const char rcsid[] =
   "$FreeBSD$";
 #endif /* not lint */
 
+#ifdef HAVE_LIBUTIL_H
+#include 
+#endif
 #include 
 #include 
 #include 
@@ -126,15 +129,38 @@ checkfilesys(const char *fname)
mod |= FSERROR;
}
 
+#ifdef HAVE_LIBUTIL_H
+   char freestr[7], badstr[7];
+
+   int64_t freebytes = boot.NumFree * boot.ClusterSize;
+   humanize_number(freestr, sizeof(freestr), freebytes, "",
+   HN_AUTOSCALE, HN_DECIMAL | HN_IEC_PREFIXES);
+   if (boot.NumBad) {
+   int64_t badbytes = boot.NumBad * boot.ClusterSize;
+
+   humanize_number(badstr, sizeof(badstr), badbytes, "",
+   HN_AUTOSCALE, HN_B | HN_DECIMAL | HN_IEC_PREFIXES);
+
+   pwarn("%d files, %sB free (%d clusters), %sB bad (%d 
clusters)\n",
+ boot.NumFiles,
+ freestr, boot.NumFree,
+ badstr, boot.NumBad);
+   } else {
+   pwarn("%d files, %sB free (%d clusters)\n",
+ boot.NumFiles,
+ freestr, boot.NumFree);
+   }
+#else
if (boot.NumBad)
-   pwarn("%d files, %d free (%d clusters), %d bad (%d clusters)\n",
+   pwarn("%d files, %d KiB free (%d clusters), %d KiB bad (%d 
clusters)\n",
  boot.NumFiles,
  boot.NumFree * boot.ClusterSize / 1024, boot.NumFree,
  boot.NumBad * boot.ClusterSize / 1024, boot.NumBad);
else
-   pwarn("%d files, %d free (%d clusters)\n",
+   pwarn("%d files, %d KiB free (%d clusters)\n",
  boot.NumFiles,
  boot.NumFree * boot.ClusterSize / 1024, boot.NumFree);
+#endif
 
if (mod && (mod & FSERROR) == 0) {
if (mod & FSDIRTY) {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r357713 - vendor/file/5.38

2020-02-09 Thread Xin LI
Author: delphij
Date: Mon Feb 10 01:34:19 2020
New Revision: 357713
URL: https://svnweb.freebsd.org/changeset/base/357713

Log:
  Tag file 5.38.

Added:
  vendor/file/5.38/
 - copied from r357712, vendor/file/dist/
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r357712 - in vendor/file/dist: . doc m4 magic magic/Magdir python src tests

2020-02-09 Thread Xin LI
Author: delphij
Date: Mon Feb 10 01:33:52 2020
New Revision: 357712
URL: https://svnweb.freebsd.org/changeset/base/357712

Log:
  Vendor import of file 5.38

Added:
  vendor/file/dist/magic/Magdir/forth
  vendor/file/dist/magic/Magdir/git
  vendor/file/dist/magic/Magdir/modulefile
  vendor/file/dist/magic/Magdir/openfst
  vendor/file/dist/magic/Magdir/opentimestamps
  vendor/file/dist/magic/Magdir/pmem
  vendor/file/dist/magic/Magdir/rst
  vendor/file/dist/magic/Magdir/sosi
  vendor/file/dist/src/is_csv.c   (contents, props changed)
Modified:
  vendor/file/dist/ChangeLog
  vendor/file/dist/Makefile.in
  vendor/file/dist/README
  vendor/file/dist/aclocal.m4
  vendor/file/dist/compile
  vendor/file/dist/config.guess
  vendor/file/dist/config.h.in
  vendor/file/dist/config.sub
  vendor/file/dist/configure
  vendor/file/dist/configure.ac
  vendor/file/dist/depcomp
  vendor/file/dist/doc/Makefile.in
  vendor/file/dist/doc/file.man
  vendor/file/dist/doc/libmagic.man
  vendor/file/dist/doc/magic.man
  vendor/file/dist/ltmain.sh
  vendor/file/dist/m4/libtool.m4
  vendor/file/dist/m4/ltoptions.m4
  vendor/file/dist/m4/ltsugar.m4
  vendor/file/dist/m4/ltversion.m4
  vendor/file/dist/m4/lt~obsolete.m4
  vendor/file/dist/magic/Magdir/android
  vendor/file/dist/magic/Magdir/animation
  vendor/file/dist/magic/Magdir/apple
  vendor/file/dist/magic/Magdir/archive
  vendor/file/dist/magic/Magdir/audio
  vendor/file/dist/magic/Magdir/bsi
  vendor/file/dist/magic/Magdir/c-lang
  vendor/file/dist/magic/Magdir/cad
  vendor/file/dist/magic/Magdir/commands
  vendor/file/dist/magic/Magdir/compress
  vendor/file/dist/magic/Magdir/console
  vendor/file/dist/magic/Magdir/database
  vendor/file/dist/magic/Magdir/elf
  vendor/file/dist/magic/Magdir/espressif
  vendor/file/dist/magic/Magdir/filesystems
  vendor/file/dist/magic/Magdir/fonts
  vendor/file/dist/magic/Magdir/frame
  vendor/file/dist/magic/Magdir/games
  vendor/file/dist/magic/Magdir/gimp
  vendor/file/dist/magic/Magdir/icc
  vendor/file/dist/magic/Magdir/images
  vendor/file/dist/magic/Magdir/javascript
  vendor/file/dist/magic/Magdir/kml
  vendor/file/dist/magic/Magdir/linux
  vendor/file/dist/magic/Magdir/macintosh
  vendor/file/dist/magic/Magdir/mail.news
  vendor/file/dist/magic/Magdir/map
  vendor/file/dist/magic/Magdir/msdos
  vendor/file/dist/magic/Magdir/msooxml
  vendor/file/dist/magic/Magdir/ole2compounddocs
  vendor/file/dist/magic/Magdir/pdf
  vendor/file/dist/magic/Magdir/python
  vendor/file/dist/magic/Magdir/rpi
  vendor/file/dist/magic/Magdir/ruby
  vendor/file/dist/magic/Magdir/sgml
  vendor/file/dist/magic/Magdir/sniffer
  vendor/file/dist/magic/Magdir/ssh
  vendor/file/dist/magic/Magdir/uuencode
  vendor/file/dist/magic/Magdir/varied.script
  vendor/file/dist/magic/Magdir/vax
  vendor/file/dist/magic/Magdir/windows
  vendor/file/dist/magic/Magdir/wordprocessors
  vendor/file/dist/magic/Magdir/zip
  vendor/file/dist/magic/Makefile.am
  vendor/file/dist/magic/Makefile.in
  vendor/file/dist/missing
  vendor/file/dist/python/Makefile.in
  vendor/file/dist/src/Makefile.am
  vendor/file/dist/src/Makefile.in
  vendor/file/dist/src/apprentice.c
  vendor/file/dist/src/ascmagic.c
  vendor/file/dist/src/buffer.c
  vendor/file/dist/src/compress.c
  vendor/file/dist/src/encoding.c
  vendor/file/dist/src/file.c
  vendor/file/dist/src/file.h
  vendor/file/dist/src/file_opts.h
  vendor/file/dist/src/fsmagic.c
  vendor/file/dist/src/funcs.c
  vendor/file/dist/src/magic.h.in
  vendor/file/dist/src/readcdf.c
  vendor/file/dist/src/readelf.c
  vendor/file/dist/src/seccomp.c
  vendor/file/dist/src/vasprintf.c
  vendor/file/dist/tests/JW07022A.mp3.result
  vendor/file/dist/tests/Makefile.in
  vendor/file/dist/tests/test.c

Modified: vendor/file/dist/ChangeLog
==
--- vendor/file/dist/ChangeLog  Mon Feb 10 00:26:41 2020(r357711)
+++ vendor/file/dist/ChangeLog  Mon Feb 10 01:33:52 2020(r357712)
@@ -1,3 +1,23 @@
+2019-12-16  21:11  Christos Zoulas 
+
+   * release 5.38
+
+2019-12-15  22:13  Christos Zoulas 
+Document changes since the previous release:
+   - Always accept -S (no sandbox) even if we don't support sandboxing
+   - More syscalls elided for sandboxiing
+   - For ELF dynamic means having an interpreter not just PT_DYNAMIC
+   - Check for large ELF session header offset
+   - When saving and restoring a locale, keep the locale name in our
+ own storage.
+   - Add a flag to disable CSV file detection.
+   - Don't pass NULL/0 to memset to appease sanitizers.
+   - Avoid spurious prints when looks for extensions or apple strings
+ in fsmagic.
+   - Add builtin decompressors for xz and and bzip.
+   - Add a limit for the number of CDF elements.
+   - More checks for overflow in CDF.
+
 2019-05-14  22:26  Christos Zoulas 
 
* release 5.37

Modified: vendor/file/dist/Makefile.in
==

svn commit: r357609 - in head/contrib/xz/src: common xz

2020-02-05 Thread Xin LI
Author: delphij
Date: Thu Feb  6 07:47:28 2020
New Revision: 357609
URL: https://svnweb.freebsd.org/changeset/base/357609

Log:
  MFV r357608: Limit memory usage in xz(1) instead of in tuklib.
  
  Apply upstream 353970510895f6a80adfe60cf71b70a95adfa8bc to limit memory
  usage on 32-bit binary to 4020 MiB.
  
  Submitted by: Lasse Collin 
  Reviewed by:  kib, bcr
  Differential Revision:https://reviews.freebsd.org/D23474

Modified:
  head/contrib/xz/src/common/tuklib_physmem.c
  head/contrib/xz/src/xz/hardware.c
  head/contrib/xz/src/xz/xz.1
Directory Properties:
  head/contrib/xz/   (props changed)

Modified: head/contrib/xz/src/common/tuklib_physmem.c
==
--- head/contrib/xz/src/common/tuklib_physmem.c Thu Feb  6 07:45:07 2020
(r357608)
+++ head/contrib/xz/src/common/tuklib_physmem.c Thu Feb  6 07:47:28 2020
(r357609)
@@ -45,7 +45,6 @@
 #  include 
 
 #elif defined(TUKLIB_PHYSMEM_SYSCONF)
-#  include 
 #  include 
 
 #elif defined(TUKLIB_PHYSMEM_SYSCTL)
@@ -146,16 +145,13 @@ tuklib_physmem(void)
 #elif defined(TUKLIB_PHYSMEM_SYSCONF)
const long pagesize = sysconf(_SC_PAGESIZE);
const long pages = sysconf(_SC_PHYS_PAGES);
-   if (pagesize != -1 && pages != -1) {
+   if (pagesize != -1 && pages != -1)
// According to docs, pagesize * pages can overflow.
// Simple case is 32-bit box with 4 GiB or more RAM,
// which may report exactly 4 GiB of RAM, and "long"
// being 32-bit will overflow. Casting to uint64_t
// hopefully avoids overflows in the near future.
ret = (uint64_t)pagesize * (uint64_t)pages;
-   if (ret > SIZE_T_MAX)
-   ret = SIZE_T_MAX;
-   }
 
 #elif defined(TUKLIB_PHYSMEM_SYSCTL)
int name[2] = {

Modified: head/contrib/xz/src/xz/hardware.c
==
--- head/contrib/xz/src/xz/hardware.c   Thu Feb  6 07:45:07 2020
(r357608)
+++ head/contrib/xz/src/xz/hardware.c   Thu Feb  6 07:47:28 2020
(r357609)
@@ -68,8 +68,38 @@ hardware_memlimit_set(uint64_t new_memlimit,
new_memlimit = (uint32_t)new_memlimit * total_ram / 100;
}
 
-   if (set_compress)
+   if (set_compress) {
memlimit_compress = new_memlimit;
+
+#if SIZE_MAX == UINT32_MAX
+   // FIXME?
+   //
+   // When running a 32-bit xz on a system with a lot of RAM and
+   // using a percentage-based memory limit, the result can be
+   // bigger than the 32-bit address space. Limiting the limit
+   // below SIZE_MAX for compression (not decompression) makes
+   // xz lower the compression settings (or number of threads)
+   // to a level that *might* work. In practice it has worked
+   // when using a 64-bit kernel that gives full 4 GiB address
+   // space to 32-bit programs. In other situations this might
+   // still be too high, like 32-bit kernels that may give much
+   // less than 4 GiB to a single application.
+   //
+   // So this is an ugly hack but I will keep it here while
+   // it does more good than bad.
+   //
+   // Use a value less than SIZE_MAX so that there's some room
+   // for the xz program and so on. Don't use 4000 MiB because
+   // it could look like someone mixed up base-2 and base-10.
+   const uint64_t limit_max = UINT64_C(4020) << 20;
+
+   // UINT64_MAX is a special case for the string "max" so
+   // that has to be handled specially.
+   if (memlimit_compress != UINT64_MAX
+   && memlimit_compress > limit_max)
+   memlimit_compress = limit_max;
+#endif
+   }
 
if (set_decompress)
memlimit_decompress = new_memlimit;

Modified: head/contrib/xz/src/xz/xz.1
==
--- head/contrib/xz/src/xz/xz.1 Thu Feb  6 07:45:07 2020(r357608)
+++ head/contrib/xz/src/xz/xz.1 Thu Feb  6 07:47:28 2020(r357609)
@@ -1005,6 +1005,25 @@ instead of
 until the details have been decided.
 .RE
 .IP ""
+For 32-bit
+.BR xz
+there is a special case: if the
+.I limit
+would be over
+.BR "4020\ MiB" ,
+the
+.I limit
+is set to
+.BR "4020\ MiB" .
+(The values
+.B 0
+and
+.B max
+aren't affected by this.
+A similar feature doesn't exist for decompression.)
+This can be helpful when a 32-bit executable has access
+to 4\ GiB address space while hopefully doing no harm in other situations.
+.IP ""
 See also the section
 .BR "Memory usage" .
 .TP
___
svn-src-all@freebsd.org mailing l

svn commit: r357608 - vendor/xz/dist/src/xz

2020-02-05 Thread Xin LI
Author: delphij
Date: Thu Feb  6 07:45:07 2020
New Revision: 357608
URL: https://svnweb.freebsd.org/changeset/base/357608

Log:
  Apply a reduced version of upstream 353970510895f6a80adfe60cf71b70a95adfa8bc
  which implements memory limit in xz(1) when running in 32-bit mode.
  
  The change is applied directly in vendor area to ease future import.

Modified:
  vendor/xz/dist/src/xz/hardware.c
  vendor/xz/dist/src/xz/xz.1

Modified: vendor/xz/dist/src/xz/hardware.c
==
--- vendor/xz/dist/src/xz/hardware.cThu Feb  6 01:25:30 2020
(r357607)
+++ vendor/xz/dist/src/xz/hardware.cThu Feb  6 07:45:07 2020
(r357608)
@@ -68,8 +68,38 @@ hardware_memlimit_set(uint64_t new_memlimit,
new_memlimit = (uint32_t)new_memlimit * total_ram / 100;
}
 
-   if (set_compress)
+   if (set_compress) {
memlimit_compress = new_memlimit;
+
+#if SIZE_MAX == UINT32_MAX
+   // FIXME?
+   //
+   // When running a 32-bit xz on a system with a lot of RAM and
+   // using a percentage-based memory limit, the result can be
+   // bigger than the 32-bit address space. Limiting the limit
+   // below SIZE_MAX for compression (not decompression) makes
+   // xz lower the compression settings (or number of threads)
+   // to a level that *might* work. In practice it has worked
+   // when using a 64-bit kernel that gives full 4 GiB address
+   // space to 32-bit programs. In other situations this might
+   // still be too high, like 32-bit kernels that may give much
+   // less than 4 GiB to a single application.
+   //
+   // So this is an ugly hack but I will keep it here while
+   // it does more good than bad.
+   //
+   // Use a value less than SIZE_MAX so that there's some room
+   // for the xz program and so on. Don't use 4000 MiB because
+   // it could look like someone mixed up base-2 and base-10.
+   const uint64_t limit_max = UINT64_C(4020) << 20;
+
+   // UINT64_MAX is a special case for the string "max" so
+   // that has to be handled specially.
+   if (memlimit_compress != UINT64_MAX
+   && memlimit_compress > limit_max)
+   memlimit_compress = limit_max;
+#endif
+   }
 
if (set_decompress)
memlimit_decompress = new_memlimit;

Modified: vendor/xz/dist/src/xz/xz.1
==
--- vendor/xz/dist/src/xz/xz.1  Thu Feb  6 01:25:30 2020(r357607)
+++ vendor/xz/dist/src/xz/xz.1  Thu Feb  6 07:45:07 2020(r357608)
@@ -1005,6 +1005,25 @@ instead of
 until the details have been decided.
 .RE
 .IP ""
+For 32-bit
+.BR xz
+there is a special case: if the
+.I limit
+would be over
+.BR "4020\ MiB" ,
+the
+.I limit
+is set to
+.BR "4020\ MiB" .
+(The values
+.B 0
+and
+.B max
+aren't affected by this.
+A similar feature doesn't exist for decompression.)
+This can be helpful when a 32-bit executable has access
+to 4\ GiB address space while hopefully doing no harm in other situations.
+.IP ""
 See also the section
 .BR "Memory usage" .
 .TP
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r357568 - stable/12/sbin/fsck_msdosfs

2020-02-05 Thread Xin LI
Author: delphij
Date: Wed Feb  5 08:55:19 2020
New Revision: 357568
URL: https://svnweb.freebsd.org/changeset/base/357568

Log:
  MFC r356249-r356250, r356313, r356434, r356657, r357421
  
  r356249-r356250, r356313:
  Reduce memory footprint of fsck_msdosfs.
  
  This utility was initially written for FAT12/16, which were inherently
  small. When FAT32 support was added, the old data structure and
  algorithms remain used with minimal changes.
  
  With growing size of FAT32 media, the current data structure that
  requires 4 32-bit variables per each FAT32 table entry would consume up
  to 4 GiB of RAM, which can be too big for systems with limited RAM
  available.
  
  Address this by taking a different approach of validating the FAT.
  
  The FAT is essentially a set of linked lists of chains that was
  referenced by directory entries, and the checker needs to make sure that
  the linked chains of clusters do not have cross-linked chains, and every
  chain were referenced by one and only one directory entry.  Instead of
  keeping track of the chain's 'head' cluster number, the size of the
  chain, the used status of the chain and the "next" pointer which is
  content of the FAT table, we create accessors for the FAT table data
  for the "next" pointer, and keep only one bit to indicate if the
  current cluster is a 'head' node of a cluster chain, in a bitmap.
  
  We further overhaul the FAT checker to find out the possible head nodes
  by excluding ones that are not (in other words, nodes that have some
  other nodes claiming them as the next node) instead of marking the head
  nodes for each node on the chain.  This approach greatly reduced the
  complexiety of computation from O(N^2) worst case, to an O(N) scan for
  worst case.  The file (cluster chain) length is not useful for the FAT
  checker, so don't bother to calculate them in the FAT checker and
  instead leave the task to the directory structure check, at which point
  we would have non-crossed cluster chains, and we are guaranteed that
  each cluster will be visited for at most one time.
  
  When checking the directory structures, we use the head node indicator
  to as the visited (used) flag: every cluster chain can only be
  referenced by one directory entry, so we clear them when calculating
  the length of the chain, and we can immediately tell if there are
  anomalies in the directory entry.
  
  As a result, the required RAM size is now 1 bit per each entry of
  the FAT table, plus memory needed to hold the FAT table in memory,
  instead of 16 bytes (=128 bits) per each entry.  For FAT12 and FAT16,
  we will load the whole FAT table into memory as they are smaller than
  128KiB, and for FAT32, we first attempt to mmap() it into memory, and
  when that fails, we would fall back to a simple LRU cache of 4 MiB of
  RAM.
  
  sbin/fsck_msdosfs/boot.c:
  
   - Added additional sanity checks for valid FAT32/FAT16/FAT12 cluster
 number.
   - FAT32: check if root directory starts with a valid cluster number,
 moved from dir.c.  There is no point to proceed if the filesystem
 is already damaged beyond repair.
  
  sbin/fsck_msdosfs/check.c:
  
   - Combine phase 1 and phase 2, now that the readfat() is able to
 detect cross chains.
  
  sbin/fsck_msdosfs/dir.c:
  
   - Refactor code to use FAT accessor instead of accessing the internal
 representation of FAT table.
   - Make use of the cluster chain head bitmap.
   - Clarify and simplify directory entry check, remove unnecessary
 checks that are would be done at a later time (for example, whether
 the directory's second cluster is a valid one, which is examined
 more throughly in a later checkchain() and does not prevent us
 from proceeding further).
  
  sbin/fsck_msdosfs/dosfs.h:
  
   - Remove internal representation of FAT table, which is replaced by
 the head bitmap that is opaque to other code.
   - Added a special CLUST_DEAD cluster type to indicate errors.
  
  sbin/fsck_msdosfs/ext.h:
  
   - Added a flag that overrides mmap(2) setting.  The corresponding
 command line option, -M is intentionally undocumented as we do not
 expect users to need it.
   - Added accessors for FAT table and convert existing interface to use
 it.
  
  sbin/fsck_msdosfs/fat.c:
  
   - Added head bitmap to represent whether a cluster is a head cluster.
   - Converted FAT internal representation to accessors.
   - Implemented a LRU cache for FAT32 when mmap(2) should not or can not
 be used.
   - _readfat: Attempt a mmap(2) and fall back to regular read for
 non-FAT32 file systems; use the LRU cache for FAT32 and prepopulate
 the cache with the first 4MiB of the entries.
   - readfat: Added support of head bitmap and use the population scan to
 detect bogus chains.
   - clusterdiff: removed, FATs are copied from the checked copy via
 writefat()/copyfat().
   - checkchain: calculates the length of a cluster chain and make sure
 that i

svn commit: r357421 - head/sbin/fsck_msdosfs

2020-02-02 Thread Xin LI
Author: delphij
Date: Sun Feb  2 20:53:31 2020
New Revision: 357421
URL: https://svnweb.freebsd.org/changeset/base/357421

Log:
  Diff reduction against NetBSD, no functional change.
  
  MFC after:1 week

Modified:
  head/sbin/fsck_msdosfs/boot.c

Modified: head/sbin/fsck_msdosfs/boot.c
==
--- head/sbin/fsck_msdosfs/boot.c   Sun Feb  2 20:51:28 2020
(r357420)
+++ head/sbin/fsck_msdosfs/boot.c   Sun Feb  2 20:53:31 2020
(r357421)
@@ -28,7 +28,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: boot.c,v 1.21 2018/02/08 09:05:17 dholland Exp $");
+__RCSID("$NetBSD: boot.c,v 1.22 2020/01/11 16:29:07 christos Exp $");
 static const char rcsid[] =
   "$FreeBSD$";
 #endif /* not lint */
@@ -267,10 +267,11 @@ readboot(int dosfs, struct bootblock *boot)
}
 
/*
-* The number of clusters is derived from available data sectors, 
divided
-* by sectors per cluster.
+* The number of clusters is derived from available data sectors,
+* divided by sectors per cluster.
 */
-   boot->NumClusters = (boot->NumSectors - boot->FirstCluster) / 
boot->bpbSecPerClust;
+   boot->NumClusters =
+   (boot->NumSectors - boot->FirstCluster) / boot->bpbSecPerClust;
 
if (boot->flags & FAT32) {
if (boot->NumClusters > (CLUST_RSRVD & CLUST32_MASK)) {
@@ -320,8 +321,8 @@ readboot(int dosfs, struct bootblock *boot)
}
 
/*
-* There are two reserved clusters.  To avoid adding CLUST_FIRST every 
time
-* when we perform boundary checks, we increment the NumClusters by 2,
+* There are two reserved clusters. To avoid adding CLUST_FIRST every
+* time we perform boundary checks, we increment the NumClusters by 2,
 * which is CLUST_FIRST to denote the first out-of-range cluster number.
 */
boot->NumClusters += CLUST_FIRST;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r357420 - head/bin/pwait

2020-02-02 Thread Xin LI
Author: delphij
Date: Sun Feb  2 20:51:28 2020
New Revision: 357420
URL: https://svnweb.freebsd.org/changeset/base/357420

Log:
  Remove unused include.
  
  MFC after:2 weeks

Modified:
  head/bin/pwait/pwait.c

Modified: head/bin/pwait/pwait.c
==
--- head/bin/pwait/pwait.c  Sun Feb  2 19:45:12 2020(r357419)
+++ head/bin/pwait/pwait.c  Sun Feb  2 20:51:28 2020(r357420)
@@ -41,7 +41,6 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r357196 - stable/12/sbin/fsck_msdosfs

2020-01-27 Thread Xin LI
Author: delphij
Date: Tue Jan 28 07:49:52 2020
New Revision: 357196
URL: https://svnweb.freebsd.org/changeset/base/357196

Log:
  MFC r356629, r356636
  
  r356629:
  Apply typo fix from NetBSD, we have already applied all NetBSD changes so
  update the NetBSD tag while I'm there.
  
  r356636:
  Correct off-by-two issue when determining FAT type.
  
  In the code we used NumClusters as the upper (non-inclusive) boundary
  of valid cluster number, so the actual value was 2 (CLUST_FIRST) more
  than the real number of clusters. This causes a FAT16 media with
  65524 clusters be treated as FAT32 and might affect FAT12 media with
  4084 clusters as well.
  
  To fix this, we increment NumClusters by CLUST_FIRST after the type
  determination.
  
  PR:   243179

Modified:
  stable/12/sbin/fsck_msdosfs/boot.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sbin/fsck_msdosfs/boot.c
==
--- stable/12/sbin/fsck_msdosfs/boot.c  Tue Jan 28 03:47:29 2020
(r357195)
+++ stable/12/sbin/fsck_msdosfs/boot.c  Tue Jan 28 07:49:52 2020
(r357196)
@@ -28,7 +28,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: boot.c,v 1.11 2006/06/05 16:51:18 christos Exp ");
+__RCSID("$NetBSD: boot.c,v 1.21 2018/02/08 09:05:17 dholland Exp $");
 static const char rcsid[] =
   "$FreeBSD$";
 #endif /* not lint */
@@ -269,8 +269,11 @@ readboot(int dosfs, struct bootblock *boot)
return FSFATAL;
}
 
-   boot->NumClusters = (boot->NumSectors - boot->FirstCluster) / 
boot->bpbSecPerClust +
-   CLUST_FIRST;
+   /*
+* The number of clusters is derived from available data sectors, 
divided
+* by sectors per cluster.
+*/
+   boot->NumClusters = (boot->NumSectors - boot->FirstCluster) / 
boot->bpbSecPerClust;
 
if (boot->flags & FAT32)
boot->ClustMask = CLUST32_MASK;
@@ -296,11 +299,19 @@ readboot(int dosfs, struct bootblock *boot)
break;
}
 
-   if (boot->NumFatEntries < boot->NumClusters - CLUST_FIRST) {
+   if (boot->NumFatEntries < boot->NumClusters) {
pfatal("FAT size too small, %u entries won't fit into %u 
sectors\n",
   boot->NumClusters, boot->FATsecs);
return FSFATAL;
}
+
+   /*
+* There are two reserved clusters.  To avoid adding CLUST_FIRST every 
time
+* when we perform boundary checks, we increment the NumClusters by 2,
+* which is CLUST_FIRST to denote the first out-of-range cluster number.
+*/
+   boot->NumClusters += CLUST_FIRST;
+
boot->ClusterSize = boot->bpbBytesPerSec * boot->bpbSecPerClust;
 
boot->NumFiles = 1;
@@ -342,7 +353,7 @@ writefsinfo(int dosfs, struct bootblock *boot)
 * support for FAT32) doesn't maintain the FSINFO block
 * correctly, it has to be fixed pretty often.
 *
-* Therefor, we handle the FSINFO block only informally,
+* Therefore, we handle the FSINFO block only informally,
 * fixing it if necessary, but otherwise ignoring the
 * fact that it was incorrect.
 */
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r356722 - stable/12/sbin/fsck_msdosfs

2020-01-13 Thread Xin LI
Author: delphij
Date: Tue Jan 14 06:28:07 2020
New Revision: 356722
URL: https://svnweb.freebsd.org/changeset/base/356722

Log:
  MFC r356628: Require FAT to occupy at least one sector.

Modified:
  stable/12/sbin/fsck_msdosfs/boot.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sbin/fsck_msdosfs/boot.c
==
--- stable/12/sbin/fsck_msdosfs/boot.c  Tue Jan 14 06:15:41 2020
(r356721)
+++ stable/12/sbin/fsck_msdosfs/boot.c  Tue Jan 14 06:28:07 2020
(r356722)
@@ -253,7 +253,7 @@ readboot(int dosfs, struct bootblock *boot)
boot->FATsecs = boot->bpbFATsmall;
}
 
-   if (boot->FATsecs > UINT32_MAX / boot->bpbFATs) {
+   if (boot->FATsecs < 1 || boot->FATsecs > UINT32_MAX / boot->bpbFATs) {
pfatal("Invalid FATs(%u) with FATsecs(%zu)",
boot->bpbFATs, (size_t)boot->FATsecs);
return FSFATAL;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r356657 - head/sbin/fsck_msdosfs

2020-01-11 Thread Xin LI
Author: delphij
Date: Sun Jan 12 06:13:52 2020
New Revision: 356657
URL: https://svnweb.freebsd.org/changeset/base/356657

Log:
  Tighten FAT checks and fix off-by-one error in corner case.
  
  sbin/fsck_msdosfs/fat.c:
   - readfat:
  * Only truncate out-of-range cluster pointers (1, or greater than
NumClusters but smaller than CLUST_RSRVD), as the current cluster
may contain some data. We can't fix reserved cluster pointers at
this pass, because we do no know the potential cluster preceding
it.
  * Accept valid cluster for head bitmap. This is a no-op, and mainly
to improve code readability, because the 1 is already handled in
the previous else if block.
   - truncate_at: absorbed into checkchain.
   - checkchain: save the previous node we have traversed in case that we
 have a chain that ends with a special (>= CLUST_RSRVD) cluster, or is
 free. In these cases, we need to truncate at the cluster preceding the
 current cluster, as the current cluster contains a marker instead of
 a next pointer and can not be changed to CLUST_EOF (the else case can
 happen if the user answered "no" at some point in readfat()).
   - clearchain: correct the iterator for next cluster so that we don't
 stop after clearing the first cluster.
   - checklost: If checkchain() thinks the chain have no cluster, it
 doesn't make sense to reconnect it, so don't bother asking.
  
  Reviewed by:  kevlo
  MFC after:24 days
  X-MFC-With:   r356313
  Differential Revision:https://reviews.freebsd.org/D23065

Modified:
  head/sbin/fsck_msdosfs/fat.c

Modified: head/sbin/fsck_msdosfs/fat.c
==
--- head/sbin/fsck_msdosfs/fat.cSun Jan 12 06:09:10 2020
(r356656)
+++ head/sbin/fsck_msdosfs/fat.cSun Jan 12 06:13:52 2020
(r356657)
@@ -935,17 +935,16 @@ readfat(int fs, struct bootblock *boot, struct fat_des
fat_clear_cl_head(fat, cl);
}
boot->NumBad++;
-   } else if (!valid_cl(fat, nextcl) && nextcl < CLUST_EOFS) {
-   pwarn("Cluster %u continues with %s "
+   } else if (!valid_cl(fat, nextcl) && nextcl < CLUST_RSRVD) {
+   pwarn("Cluster %u continues with out of range "
"cluster number %u\n",
-   cl, (nextcl < CLUST_RSRVD) ?
-   "out of range" : "reserved",
+   cl,
nextcl & boot->ClustMask);
if (ask(0, "Truncate")) {
ret |= fat_set_cl_next(fat, cl, CLUST_EOF);
ret |= FSFATMOD;
}
-   } else if (nextcl < boot->NumClusters) {
+   } else if (valid_cl(fat, nextcl)) {
if (fat_is_cl_head(fat, nextcl)) {
fat_clear_cl_head(fat, nextcl);
} else {
@@ -985,29 +984,13 @@ rsrvdcltype(cl_t cl)
 }
 
 /*
- * Offer to truncate a chain at the specified CL, called by checkchain().
- */
-static inline int
-truncate_at(struct fat_descriptor *fat, cl_t current_cl, size_t *chainsize)
-{
-   int ret = 0;
-
-   if (ask(0, "Truncate")) {
-   ret = fat_set_cl_next(fat, current_cl, CLUST_EOF);
-   (*chainsize)++;
-   return (ret | FSFATMOD);
-   } else {
-   return FSERROR;
-   }
-}
-
-/*
  * Examine a cluster chain for errors and count its size.
  */
 int
 checkchain(struct fat_descriptor *fat, cl_t head, size_t *chainsize)
 {
-   cl_t current_cl, next_cl;
+   cl_t prev_cl, current_cl, next_cl;
+   const char *op;
 
/*
 * We expect that the caller to give us a real, unvisited 'head'
@@ -1038,10 +1021,10 @@ checkchain(struct fat_descriptor *fat, cl_t head, size
 * it as EOF) when the next node violates that.
 */
*chainsize = 0;
-   current_cl = head;
+   prev_cl = current_cl = head;
for (next_cl = fat_get_cl_next(fat, current_cl);
valid_cl(fat, next_cl);
-   current_cl = next_cl, next_cl = fat_get_cl_next(fat, current_cl))
+   prev_cl = current_cl, current_cl = next_cl, next_cl = 
fat_get_cl_next(fat, current_cl))
(*chainsize)++;
 
/* A natural end */
@@ -1050,12 +1033,40 @@ checkchain(struct fat_descriptor *fat, cl_t head, size
return FSOK;
}
 
-   /* The chain ended with an out-of-range cluster number. */
-   pwarn("Cluster %u continues with %s cluster number %u\n",
-   current_cl,
-   next_cl < CLUST_RSRVD ? "out of range" : "reserved",
-   next_cl & boot_of_(fat)->ClustMask);
-   return (truncate_at(fat, current_cl, chainsize));
+   /*
+*

svn commit: r356636 - head/sbin/fsck_msdosfs

2020-01-11 Thread Xin LI
Author: delphij
Date: Sat Jan 11 17:41:20 2020
New Revision: 356636
URL: https://svnweb.freebsd.org/changeset/base/356636

Log:
  Correct off-by-two issue when determining FAT type.
  
  In the code we used NumClusters as the upper (non-inclusive) boundary
  of valid cluster number, so the actual value was 2 (CLUST_FIRST) more
  than the real number of clusters. This causes a FAT16 media with
  65524 clusters be treated as FAT32 and might affect FAT12 media with
  4084 clusters as well.
  
  To fix this, we increment NumClusters by CLUST_FIRST after the type
  determination.
  
  PR:   243179
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D23082

Modified:
  head/sbin/fsck_msdosfs/boot.c

Modified: head/sbin/fsck_msdosfs/boot.c
==
--- head/sbin/fsck_msdosfs/boot.c   Sat Jan 11 16:28:35 2020
(r356635)
+++ head/sbin/fsck_msdosfs/boot.c   Sat Jan 11 17:41:20 2020
(r356636)
@@ -266,8 +266,11 @@ readboot(int dosfs, struct bootblock *boot)
return FSFATAL;
}
 
-   boot->NumClusters = (boot->NumSectors - boot->FirstCluster) / 
boot->bpbSecPerClust +
-   CLUST_FIRST;
+   /*
+* The number of clusters is derived from available data sectors, 
divided
+* by sectors per cluster.
+*/
+   boot->NumClusters = (boot->NumSectors - boot->FirstCluster) / 
boot->bpbSecPerClust;
 
if (boot->flags & FAT32) {
if (boot->NumClusters > (CLUST_RSRVD & CLUST32_MASK)) {
@@ -310,11 +313,19 @@ readboot(int dosfs, struct bootblock *boot)
break;
}
 
-   if (boot->NumFatEntries < boot->NumClusters - CLUST_FIRST) {
+   if (boot->NumFatEntries < boot->NumClusters) {
pfatal("FAT size too small, %u entries won't fit into %u 
sectors\n",
   boot->NumClusters, boot->FATsecs);
return FSFATAL;
}
+
+   /*
+* There are two reserved clusters.  To avoid adding CLUST_FIRST every 
time
+* when we perform boundary checks, we increment the NumClusters by 2,
+* which is CLUST_FIRST to denote the first out-of-range cluster number.
+*/
+   boot->NumClusters += CLUST_FIRST;
+
boot->ClusterSize = boot->bpbBytesPerSec * boot->bpbSecPerClust;
 
boot->NumFiles = 1;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r356629 - head/sbin/fsck_msdosfs

2020-01-10 Thread Xin LI
Author: delphij
Date: Sat Jan 11 04:02:40 2020
New Revision: 356629
URL: https://svnweb.freebsd.org/changeset/base/356629

Log:
  Apply typo fix from NetBSD, we have already applied all NetBSD changes so
  update the NetBSD tag while I'm there.
  
  MFC after:2 weeks

Modified:
  head/sbin/fsck_msdosfs/boot.c

Modified: head/sbin/fsck_msdosfs/boot.c
==
--- head/sbin/fsck_msdosfs/boot.c   Sat Jan 11 03:59:06 2020
(r356628)
+++ head/sbin/fsck_msdosfs/boot.c   Sat Jan 11 04:02:40 2020
(r356629)
@@ -28,7 +28,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: boot.c,v 1.11 2006/06/05 16:51:18 christos Exp ");
+__RCSID("$NetBSD: boot.c,v 1.21 2018/02/08 09:05:17 dholland Exp $");
 static const char rcsid[] =
   "$FreeBSD$";
 #endif /* not lint */
@@ -356,7 +356,7 @@ writefsinfo(int dosfs, struct bootblock *boot)
 * support for FAT32) doesn't maintain the FSINFO block
 * correctly, it has to be fixed pretty often.
 *
-* Therefor, we handle the FSINFO block only informally,
+* Therefore, we handle the FSINFO block only informally,
 * fixing it if necessary, but otherwise ignoring the
 * fact that it was incorrect.
 */
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r356628 - head/sbin/fsck_msdosfs

2020-01-10 Thread Xin LI
Author: delphij
Date: Sat Jan 11 03:59:06 2020
New Revision: 356628
URL: https://svnweb.freebsd.org/changeset/base/356628

Log:
  Require FAT to occupy at least one sector.
  
  Obtained from:Android https://r.android.com/1205830
  MFC after:3 days

Modified:
  head/sbin/fsck_msdosfs/boot.c

Modified: head/sbin/fsck_msdosfs/boot.c
==
--- head/sbin/fsck_msdosfs/boot.c   Sat Jan 11 03:18:47 2020
(r356627)
+++ head/sbin/fsck_msdosfs/boot.c   Sat Jan 11 03:59:06 2020
(r356628)
@@ -250,7 +250,7 @@ readboot(int dosfs, struct bootblock *boot)
boot->FATsecs = boot->bpbFATsmall;
}
 
-   if (boot->FATsecs > UINT32_MAX / boot->bpbFATs) {
+   if (boot->FATsecs < 1 || boot->FATsecs > UINT32_MAX / boot->bpbFATs) {
pfatal("Invalid FATs(%u) with FATsecs(%zu)",
boot->bpbFATs, (size_t)boot->FATsecs);
return FSFATAL;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r356434 - head/sbin/fsck_msdosfs

2020-01-06 Thread Xin LI
Author: delphij
Date: Tue Jan  7 04:33:14 2020
New Revision: 356434
URL: https://svnweb.freebsd.org/changeset/base/356434

Log:
  fsck_msdosfs.8: document -M.
  
  Reported by:  mckusick
  Reviewed by:  mckusick, emaste, bcr
  MFC after:28 days
  X-MFC-with:   r356313
  Differential Revision:https://reviews.freebsd.org/D23049

Modified:
  head/sbin/fsck_msdosfs/fsck_msdosfs.8

Modified: head/sbin/fsck_msdosfs/fsck_msdosfs.8
==
--- head/sbin/fsck_msdosfs/fsck_msdosfs.8   Tue Jan  7 04:30:49 2020
(r356433)
+++ head/sbin/fsck_msdosfs/fsck_msdosfs.8   Tue Jan  7 04:33:14 2020
(r356434)
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd October 3, 2016
+.Dd January 6, 2020
 .Dt FSCK_MSDOSFS 8
 .Os
 .Sh NAME
@@ -37,7 +37,7 @@
 .Op Fl Cf
 .Ar filesystem ...
 .Nm
-.Op Fl Cny
+.Op Fl CMny
 .Ar filesystem ...
 .Sh DESCRIPTION
 The
@@ -84,6 +84,21 @@ which seeks to determine whether the file system needs
 immediately in foreground, or if its cleaning can be deferred to background.
 FAT (MS-DOS) file systems must always be cleaned in the foreground.
 A non-zero exit code is always returned for this option.
+.It Fl M
+Causes
+.Nm
+to not use
+.Xr mmap 2
+when checking a FAT32 file system.
+This option is mainly for debugging purposes and is not normally necessary.
+The
+.Nm
+utility will automatically fall back to use a simple LRU cache of 4 MiB
+when it failed to perform
+.Xr mmap 2 ,
+or when
+.Fl M
+is specified.
 .It Fl f
 Force
 .Nm
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r356313 - head/sbin/fsck_msdosfs

2020-01-02 Thread Xin LI
Author: delphij
Date: Fri Jan  3 00:31:48 2020
New Revision: 356313
URL: https://svnweb.freebsd.org/changeset/base/356313

Log:
  Reduce memory footprint of fsck_msdosfs.
  
  This is a re-apply r356249 with changes to make GCC happy.
  
  This utility was initially written for FAT12/16, which were inherently
  small. When FAT32 support was added, the old data structure and
  algorithms remain used with minimal changes.
  
  With growing size of FAT32 media, the current data structure that
  requires 4 32-bit variables per each FAT32 table entry would consume up
  to 4 GiB of RAM, which can be too big for systems with limited RAM
  available.
  
  Address this by taking a different approach of validating the FAT.
  
  The FAT is essentially a set of linked lists of chains that was
  referenced by directory entries, and the checker needs to make sure that
  the linked chains of clusters do not have cross-linked chains, and every
  chain were referenced by one and only one directory entry.  Instead of
  keeping track of the chain's 'head' cluster number, the size of the
  chain, the used status of the chain and the "next" pointer which is
  content of the FAT table, we create accessors for the FAT table data
  for the "next" pointer, and keep only one bit to indicate if the
  current cluster is a 'head' node of a cluster chain, in a bitmap.
  
  We further overhaul the FAT checker to find out the possible head nodes
  by excluding ones that are not (in other words, nodes that have some
  other nodes claiming them as the next node) instead of marking the head
  nodes for each node on the chain.  This approach greatly reduced the
  complexiety of computation from O(N^2) worst case, to an O(N) scan for
  worst case.  The file (cluster chain) length is not useful for the FAT
  checker, so don't bother to calculate them in the FAT checker and
  instead leave the task to the directory structure check, at which point
  we would have non-crossed cluster chains, and we are guaranteed that
  each cluster will be visited for at most one time.
  
  When checking the directory structures, we use the head node indicator
  to as the visited (used) flag: every cluster chain can only be
  referenced by one directory entry, so we clear them when calculating
  the length of the chain, and we can immediately tell if there are
  anomalies in the directory entry.
  
  As a result, the required RAM size is now 1 bit per each entry of
  the FAT table, plus memory needed to hold the FAT table in memory,
  instead of 16 bytes (=128 bits) per each entry.  For FAT12 and FAT16,
  we will load the whole FAT table into memory as they are smaller than
  128KiB, and for FAT32, we first attempt to mmap() it into memory, and
  when that fails, we would fall back to a simple LRU cache of 4 MiB of
  RAM.
  
  sbin/fsck_msdosfs/boot.c:
  
   - Added additional sanity checks for valid FAT32/FAT16/FAT12 cluster
 number.
   - FAT32: check if root directory starts with a valid cluster number,
 moved from dir.c.  There is no point to proceed if the filesystem
 is already damaged beyond repair.
  
  sbin/fsck_msdosfs/check.c:
  
   - Combine phase 1 and phase 2, now that the readfat() is able to
 detect cross chains.
  
  sbin/fsck_msdosfs/dir.c:
  
   - Refactor code to use FAT accessor instead of accessing the internal
 representation of FAT table.
   - Make use of the cluster chain head bitmap.
   - Clarify and simplify directory entry check, remove unnecessary
 checks that are would be done at a later time (for example, whether
 the directory's second cluster is a valid one, which is examined
 more throughly in a later checkchain() and does not prevent us
 from proceeding further).
  
  sbin/fsck_msdosfs/dosfs.h:
  
   - Remove internal representation of FAT table, which is replaced by
 the head bitmap that is opaque to other code.
   - Added a special CLUST_DEAD cluster type to indicate errors.
  
  sbin/fsck_msdosfs/ext.h:
  
   - Added a flag that overrides mmap(2) setting.  The corresponding
 command line option, -M is intentionally undocumented as we do not
 expect users to need it.
   - Added accessors for FAT table and convert existing interface to use
 it.
  
  sbin/fsck_msdosfs/fat.c:
  
   - Added head bitmap to represent whether a cluster is a head cluster.
   - Converted FAT internal representation to accessors.
   - Implemented a LRU cache for FAT32 when mmap(2) should not or can not
 be used.
   - _readfat: Attempt a mmap(2) and fall back to regular read for
 non-FAT32 file systems; use the LRU cache for FAT32 and prepopulate
 the cache with the first 4MiB of the entries.
   - readfat: Added support of head bitmap and use the population scan to
 detect bogus chains.
   - clusterdiff: removed, FATs are copied from the checked copy via
 writefat()/copyfat().
   - checkchain: calculates the length of a cluster chain and make sure
 that it ends with a valid EOF m

svn commit: r356250 - head/sbin/fsck_msdosfs

2020-01-01 Thread Xin LI
Author: delphij
Date: Wed Jan  1 09:22:06 2020
New Revision: 356250
URL: https://svnweb.freebsd.org/changeset/base/356250

Log:
  Revert r356249 for now as it broke GCC builds.

Modified:
  head/sbin/fsck_msdosfs/boot.c
  head/sbin/fsck_msdosfs/check.c
  head/sbin/fsck_msdosfs/dir.c
  head/sbin/fsck_msdosfs/dosfs.h
  head/sbin/fsck_msdosfs/ext.h
  head/sbin/fsck_msdosfs/fat.c
  head/sbin/fsck_msdosfs/main.c

Modified: head/sbin/fsck_msdosfs/boot.c
==
--- head/sbin/fsck_msdosfs/boot.c   Wed Jan  1 07:43:08 2020
(r356249)
+++ head/sbin/fsck_msdosfs/boot.c   Wed Jan  1 09:22:06 2020
(r356250)
@@ -152,6 +152,9 @@ readboot(int dosfs, struct bootblock *boot)
boot->NumSectors = boot->bpbHugeSectors;
}
 
+
+
+
if (boot->flags & FAT32) {
/* If the OEM Name field is EXFAT, it's not FAT32, so bail */
if (!memcmp(&block[3], "EXFAT   ", 8)) {
@@ -269,30 +272,13 @@ readboot(int dosfs, struct bootblock *boot)
boot->NumClusters = (boot->NumSectors - boot->FirstCluster) / 
boot->bpbSecPerClust +
CLUST_FIRST;
 
-   if (boot->flags & FAT32) {
-   if (boot->NumClusters > (CLUST_RSRVD & CLUST32_MASK)) {
-   pfatal("Filesystem too big (%u clusters) for FAT32 
partition",
-   boot->NumClusters);
-   return FSFATAL;
-   }
-   if (boot->NumClusters < (CLUST_RSRVD & CLUST16_MASK)) {
-   pfatal("Filesystem too small (%u clusters) for FAT32 
partition",
-   boot->NumClusters);
-   return FSFATAL;
-   }
+   if (boot->flags & FAT32)
boot->ClustMask = CLUST32_MASK;
-
-   if (boot->bpbRootClust < CLUST_FIRST ||
-   boot->bpbRootClust >= boot->NumClusters) {
-   pfatal("Root directory starts with cluster out of 
range(%u)",
-  boot->bpbRootClust);
-   return FSFATAL;
-   }
-   } else if (boot->NumClusters < (CLUST_RSRVD&CLUST12_MASK)) {
+   else if (boot->NumClusters < (CLUST_RSRVD&CLUST12_MASK))
boot->ClustMask = CLUST12_MASK;
-   } else if (boot->NumClusters < (CLUST_RSRVD&CLUST16_MASK)) {
+   else if (boot->NumClusters < (CLUST_RSRVD&CLUST16_MASK))
boot->ClustMask = CLUST16_MASK;
-   } else {
+   else {
pfatal("Filesystem too big (%u clusters) for non-FAT32 
partition",
   boot->NumClusters);
return FSFATAL;

Modified: head/sbin/fsck_msdosfs/check.c
==
--- head/sbin/fsck_msdosfs/check.c  Wed Jan  1 07:43:08 2020
(r356249)
+++ head/sbin/fsck_msdosfs/check.c  Wed Jan  1 09:22:06 2020
(r356250)
@@ -47,8 +47,9 @@ checkfilesys(const char *fname)
 {
int dosfs;
struct bootblock boot;
-   struct fat_descriptor *fat = NULL;
+   struct fatEntry *fat = NULL;
int finish_dosdirsection=0;
+   u_int i;
int mod = 0;
int ret = 8;
 
@@ -87,39 +88,65 @@ checkfilesys(const char *fname)
}
 
if (!preen)  {
-   printf("** Phase 1 - Read FAT and checking connectivity\n");
+   if (boot.ValidFat < 0)
+   printf("** Phase 1 - Read and Compare FATs\n");
+   else
+   printf("** Phase 1 - Read FAT\n");
}
 
-   mod |= readfat(dosfs, &boot, &fat);
+   mod |= readfat(dosfs, &boot, boot.ValidFat >= 0 ? boot.ValidFat : 0, 
&fat);
if (mod & FSFATAL) {
close(dosfs);
return 8;
}
 
+   if (boot.ValidFat < 0)
+   for (i = 1; i < boot.bpbFATs; i++) {
+   struct fatEntry *currentFat;
+
+   mod |= readfat(dosfs, &boot, i, ¤tFat);
+
+   if (mod & FSFATAL)
+   goto out;
+
+   mod |= comparefat(&boot, fat, currentFat, i);
+   free(currentFat);
+   if (mod & FSFATAL)
+   goto out;
+   }
+
if (!preen)
-   printf("** Phase 2 - Checking Directories\n");
+   printf("** Phase 2 - Check Cluster Chains\n");
 
-   mod |= resetDosDirSection(fat);
+   mod |= checkfat(&boot, fat);
+   if (mod & FSFATAL)
+   goto out;
+   /* delay writing FATs */
+
+   if (!preen)
+   printf("** Phase 3 - Checking Directories\n");
+
+   mod |= resetDosDirSection(&boot, fat);
finish_dosdirsection = 1;
if (mod & FSFATAL)
goto out;
/* delay writing FATs */
 
-   mod |= handleDirTree(fat);
+   mod 

svn commit: r356249 - head/sbin/fsck_msdosfs

2019-12-31 Thread Xin LI
Author: delphij
Date: Wed Jan  1 07:43:08 2020
New Revision: 356249
URL: https://svnweb.freebsd.org/changeset/base/356249

Log:
  Reduce memory footprint of fsck_msdosfs.
  
  This utility was initially written for FAT12/16, which were inherently
  small. When FAT32 support was added, the old data structure and
  algorithms remain used with minimal changes.
  
  With growing size of FAT32 media, the current data structure that
  requires 4 32-bit variables per each FAT32 table entry would consume up
  to 4 GiB of RAM, which can be too big for systems with limited RAM
  available.
  
  Address this by taking a different approach of validating the FAT.
  
  The FAT is essentially a set of linked lists of chains that was
  referenced by directory entries, and the checker needs to make sure that
  the linked chains of clusters do not have cross-linked chains, and every
  chain were referenced by one and only one directory entry.  Instead of
  keeping track of the chain's 'head' cluster number, the size of the
  chain, the used status of the chain and the "next" pointer which is
  content of the FAT table, we create accessors for the FAT table data
  for the "next" pointer, and keep only one bit to indicate if the
  current cluster is a 'head' node of a cluster chain, in a bitmap.
  
  We further overhaul the FAT checker to find out the possible head nodes
  by excluding ones that are not (in other words, nodes that have some
  other nodes claiming them as the next node) instead of marking the head
  nodes for each node on the chain.  This approach greatly reduced the
  complexiety of computation from O(N^2) worst case, to an O(N) scan for
  worst case.  The file (cluster chain) length is not useful for the FAT
  checker, so don't bother to calculate them in the FAT checker and
  instead leave the task to the directory structure check, at which point
  we would have non-crossed cluster chains, and we are guaranteed that
  each cluster will be visited for at most one time.
  
  When checking the directory structures, we use the head node indicator
  to as the visited (used) flag: every cluster chain can only be
  referenced by one directory entry, so we clear them when calculating
  the length of the chain, and we can immediately tell if there are
  anomalies in the directory entry.
  
  As a result, the required RAM size is now 1 bit per each entry of
  the FAT table, plus memory needed to hold the FAT table in memory,
  instead of 16 bytes (=128 bits) per each entry.  For FAT12 and FAT16,
  we will load the whole FAT table into memory as they are smaller than
  128KiB, and for FAT32, we first attempt to mmap() it into memory, and
  when that fails, we would fall back to a simple LRU cache of 4 MiB of
  RAM.
  
  sbin/fsck_msdosfs/boot.c:
  
   - Added additional sanity checks for valid FAT32/FAT16/FAT12 cluster
 number.
   - FAT32: check if root directory starts with a valid cluster number,
 moved from dir.c.  There is no point to proceed if the filesystem
 is already damaged beyond repair.
  
  sbin/fsck_msdosfs/check.c:
  
   - Combine phase 1 and phase 2, now that the readfat() is able to
 detect cross chains.
  
  sbin/fsck_msdosfs/dir.c:
  
   - Refactor code to use FAT accessor instead of accessing the internal
 representation of FAT table.
   - Make use of the cluster chain head bitmap.
   - Clarify and simplify directory entry check, remove unnecessary
 checks that are would be done at a later time (for example, whether
 the directory's second cluster is a valid one, which is examined
 more throughly in a later checkchain() and does not prevent us
 from proceeding further).
  
  sbin/fsck_msdosfs/dosfs.h:
  
   - Remove internal representation of FAT table, which is replaced by
 the head bitmap that is opaque to other code.
   - Added a special CLUST_DEAD cluster type to indicate errors.
  
  sbin/fsck_msdosfs/ext.h:
  
   - Added a flag that overrides mmap(2) setting.  The corresponding
 command line option, -M is intentionally undocumented as we do not
 expect users to need it.
   - Added accessors for FAT table and convert existing interface to use
 it.
  
  sbin/fsck_msdosfs/fat.c:
  
   - Added head bitmap to represent whether a cluster is a head cluster.
   - Converted FAT internal representation to accessors.
   - Implemented a LRU cache for FAT32 when mmap(2) should not or can not
 be used.
   - _readfat: Attempt a mmap(2) and fall back to regular read for
 non-FAT32 file systems; use the LRU cache for FAT32 and prepopulate
 the cache with the first 4MiB of the entries.
   - readfat: Added support of head bitmap and use the population scan to
 detect bogus chains.
   - clusterdiff: removed, FATs are copied from the checked copy via
 writefat()/copyfat().
   - checkchain: calculates the length of a cluster chain and make sure
 that it ends with a valid EOF marker.
   - clearchain: follow and clear a chain and maintain th

svn commit: r356000 - in head/sbin: fsck fsck_ffs

2019-12-21 Thread Xin LI
Author: delphij
Date: Sun Dec 22 05:44:29 2019
New Revision: 356000
URL: https://svnweb.freebsd.org/changeset/base/356000

Log:
  Remove unused includes.
  
  MFC after:2 weeks

Modified:
  head/sbin/fsck/fsck.c
  head/sbin/fsck/fsutil.c
  head/sbin/fsck_ffs/utilities.c

Modified: head/sbin/fsck/fsck.c
==
--- head/sbin/fsck/fsck.c   Sun Dec 22 05:43:13 2019(r355999)
+++ head/sbin/fsck/fsck.c   Sun Dec 22 05:44:29 2019(r356000)
@@ -48,7 +48,6 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 

Modified: head/sbin/fsck/fsutil.c
==
--- head/sbin/fsck/fsutil.c Sun Dec 22 05:43:13 2019(r355999)
+++ head/sbin/fsck/fsutil.c Sun Dec 22 05:44:29 2019(r356000)
@@ -42,8 +42,6 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #include 
-#include 
-#include 
 #include 
 #include 
 #include 

Modified: head/sbin/fsck_ffs/utilities.c
==
--- head/sbin/fsck_ffs/utilities.c  Sun Dec 22 05:43:13 2019
(r355999)
+++ head/sbin/fsck_ffs/utilities.c  Sun Dec 22 05:44:29 2019
(r356000)
@@ -45,15 +45,11 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
-#include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
-#include 
-#include 
 
 #include "fsck.h"
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r355999 - stable/11/sbin/newfs_msdos

2019-12-21 Thread Xin LI
Author: delphij
Date: Sun Dec 22 05:43:13 2019
New Revision: 355999
URL: https://svnweb.freebsd.org/changeset/base/355999

Log:
  MFC r355318, r355513
  
  r355318:
  Explicitly exit() instead of return in main().
  
  r355513:
  Fix a couple of minor issues with newfs_msdos:
  
   - Do not unnecessarily strdup().
   - Check return value of getdiskinfo(), if it failed, bail out.

Modified:
  stable/11/sbin/newfs_msdos/mkfs_msdos.c
  stable/11/sbin/newfs_msdos/newfs_msdos.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sbin/newfs_msdos/mkfs_msdos.c
==
--- stable/11/sbin/newfs_msdos/mkfs_msdos.c Sun Dec 22 05:39:26 2019
(r355998)
+++ stable/11/sbin/newfs_msdos/mkfs_msdos.c Sun Dec 22 05:43:13 2019
(r355999)
@@ -316,7 +316,8 @@ mkfs_msdos(const char *fname, const char *dtype, const
bpb.bpbHiddenSecs = o.hidden_sectors;
 if (!(o.floppy || (o.drive_heads && o.sectors_per_track &&
o.bytes_per_sector && o.size && o.hidden_sectors_set))) {
-   getdiskinfo(fd, fname, dtype, o.hidden_sectors_set, &bpb);
+   if (getdiskinfo(fd, fname, dtype, o.hidden_sectors_set, &bpb) == -1)
+   goto done;
bpb.bpbHugeSectors -= (o.offset / bpb.bpbBytesPerSec);
if (bpb.bpbSecPerClust == 0) {  /* set defaults */
if (bpb.bpbHugeSectors <= 6000) /* about 3MB -> 512 bytes */
@@ -421,10 +422,7 @@ mkfs_msdos(const char *fname, const char *dtype, const
bname = o.bootstrap;
if (!strchr(bname, '/')) {
snprintf(buf, sizeof(buf), "/boot/%s", bname);
-   if (!(bname = strdup(buf))) {
-   warn(NULL);
-   goto done;
-   }
+   bname = buf;
}
if ((fd1 = open(bname, O_RDONLY)) == -1 || fstat(fd1, &sb)) {
warn("%s", bname);

Modified: stable/11/sbin/newfs_msdos/newfs_msdos.c
==
--- stable/11/sbin/newfs_msdos/newfs_msdos.cSun Dec 22 05:39:26 2019
(r355998)
+++ stable/11/sbin/newfs_msdos/newfs_msdos.cSun Dec 22 05:43:13 2019
(r355999)
@@ -185,11 +185,10 @@ main(int argc, char *argv[])
 fname = *argv++;
 if (!o.create_size && !strchr(fname, '/')) {
snprintf(buf, sizeof(buf), "%s%s", _PATH_DEV, fname);
-   if (!(fname = strdup(buf)))
-   err(1, NULL);
+   fname = buf;
 }
 dtype = *argv;
-return !!mkfs_msdos(fname, dtype, &o);
+exit(!!mkfs_msdos(fname, dtype, &o));
 }
 
 /*
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r355998 - stable/12/sbin/newfs_msdos

2019-12-21 Thread Xin LI
Author: delphij
Date: Sun Dec 22 05:39:26 2019
New Revision: 355998
URL: https://svnweb.freebsd.org/changeset/base/355998

Log:
  MFC r355318, r355513
  
  r355318:
  Explicitly exit() instead of return in main().
  
  r355513:
  Fix a couple of minor issues with newfs_msdos:
  
   - Do not unnecessarily strdup().
   - Check return value of getdiskinfo(), if it failed, bail out.

Modified:
  stable/12/sbin/newfs_msdos/mkfs_msdos.c
  stable/12/sbin/newfs_msdos/newfs_msdos.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sbin/newfs_msdos/mkfs_msdos.c
==
--- stable/12/sbin/newfs_msdos/mkfs_msdos.c Sun Dec 22 04:21:16 2019
(r355997)
+++ stable/12/sbin/newfs_msdos/mkfs_msdos.c Sun Dec 22 05:39:26 2019
(r355998)
@@ -316,7 +316,8 @@ mkfs_msdos(const char *fname, const char *dtype, const
bpb.bpbHiddenSecs = o.hidden_sectors;
 if (!(o.floppy || (o.drive_heads && o.sectors_per_track &&
o.bytes_per_sector && o.size && o.hidden_sectors_set))) {
-   getdiskinfo(fd, fname, dtype, o.hidden_sectors_set, &bpb);
+   if (getdiskinfo(fd, fname, dtype, o.hidden_sectors_set, &bpb) == -1)
+   goto done;
bpb.bpbHugeSectors -= (o.offset / bpb.bpbBytesPerSec);
if (bpb.bpbSecPerClust == 0) {  /* set defaults */
if (bpb.bpbHugeSectors <= 6000) /* about 3MB -> 512 bytes */
@@ -421,10 +422,7 @@ mkfs_msdos(const char *fname, const char *dtype, const
bname = o.bootstrap;
if (!strchr(bname, '/')) {
snprintf(buf, sizeof(buf), "/boot/%s", bname);
-   if (!(bname = strdup(buf))) {
-   warn(NULL);
-   goto done;
-   }
+   bname = buf;
}
if ((fd1 = open(bname, O_RDONLY)) == -1 || fstat(fd1, &sb)) {
warn("%s", bname);

Modified: stable/12/sbin/newfs_msdos/newfs_msdos.c
==
--- stable/12/sbin/newfs_msdos/newfs_msdos.cSun Dec 22 04:21:16 2019
(r355997)
+++ stable/12/sbin/newfs_msdos/newfs_msdos.cSun Dec 22 05:39:26 2019
(r355998)
@@ -185,11 +185,10 @@ main(int argc, char *argv[])
 fname = *argv++;
 if (!o.create_size && !strchr(fname, '/')) {
snprintf(buf, sizeof(buf), "%s%s", _PATH_DEV, fname);
-   if (!(fname = strdup(buf)))
-   err(1, NULL);
+   fname = buf;
 }
 dtype = *argv;
-return !!mkfs_msdos(fname, dtype, &o);
+exit(!!mkfs_msdos(fname, dtype, &o));
 }
 
 /*
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r355877 - stable/12/sbin/newfs_msdos

2019-12-18 Thread Xin LI
Author: delphij
Date: Wed Dec 18 08:08:51 2019
New Revision: 355877
URL: https://svnweb.freebsd.org/changeset/base/355877

Log:
  MFC r355317:
  
  newfs_msdos: -A is incompatible with -r, not -o.
  
  PR:   242314
  Submitted by: Guy Yur 

Modified:
  stable/12/sbin/newfs_msdos/newfs_msdos.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sbin/newfs_msdos/newfs_msdos.c
==
--- stable/12/sbin/newfs_msdos/newfs_msdos.cWed Dec 18 06:22:28 2019
(r355876)
+++ stable/12/sbin/newfs_msdos/newfs_msdos.cWed Dec 18 08:08:51 2019
(r355877)
@@ -179,7 +179,7 @@ main(int argc, char *argv[])
 if (argc < 1 || argc > 2)
usage();
if (o.align) {
-   if (o.hidden_sectors_set)
+   if (o.reserved_sectors)
errx(1, "align (-A) is incompatible with -r");
}
 fname = *argv++;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r355772 - in stable/12: libexec/getty sbin/ipfw

2019-12-15 Thread Xin LI
Author: delphij
Date: Sun Dec 15 08:23:38 2019
New Revision: 355772
URL: https://svnweb.freebsd.org/changeset/base/355772

Log:
  MFC r355222, r355260:
  
  r355222: Use strlcat().
  r355260: Simplify code with strlcpy/strlcat.

Modified:
  stable/12/libexec/getty/main.c
  stable/12/libexec/getty/subr.c
  stable/12/sbin/ipfw/dummynet.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/libexec/getty/main.c
==
--- stable/12/libexec/getty/main.c  Sun Dec 15 06:26:47 2019
(r355771)
+++ stable/12/libexec/getty/main.c  Sun Dec 15 08:23:38 2019
(r355772)
@@ -97,7 +97,6 @@ static int crmod, digit, lower, upper;
 
 char   hostname[MAXHOSTNAMELEN];
 static charname[MAXLOGNAME*3];
-static chardev[] = _PATH_DEV;
 static charttyn[32];
 
 #defineOBUFSIZ 128
@@ -218,8 +217,8 @@ main(int argc, char *argv[])
if (argc <= 2 || strcmp(argv[2], "-") == 0)
strcpy(ttyn, ttyname(STDIN_FILENO));
else {
-   strcpy(ttyn, dev);
-   strncat(ttyn, argv[2], sizeof(ttyn)-sizeof(dev));
+   strcpy(ttyn, _PATH_DEV);
+   strlcat(ttyn, argv[2], sizeof(ttyn));
if (strcmp(argv[0], "+") != 0) {
chown(ttyn, 0, 0);
chmod(ttyn, 0600);

Modified: stable/12/libexec/getty/subr.c
==
--- stable/12/libexec/getty/subr.c  Sun Dec 15 06:26:47 2019
(r355771)
+++ stable/12/libexec/getty/subr.c  Sun Dec 15 08:23:38 2019
(r355772)
@@ -89,10 +89,8 @@ gettable(const char *name, char *buf)
l = 2;
else
l = strlen(sp->value) + 1;
-   if ((p = malloc(l)) != NULL) {
-   strncpy(p, sp->value, l);
-   p[l-1] = '\0';
-   }
+   if ((p = malloc(l)) != NULL)
+   strlcpy(p, sp->value, l);
/*
 * replace, even if NULL, else we'll
 * have problems with free()ing static mem

Modified: stable/12/sbin/ipfw/dummynet.c
==
--- stable/12/sbin/ipfw/dummynet.c  Sun Dec 15 06:26:47 2019
(r355771)
+++ stable/12/sbin/ipfw/dummynet.c  Sun Dec 15 08:23:38 2019
(r355772)
@@ -497,7 +497,7 @@ print_flowset_parms(struct dn_fs *fs, char *prefix)
fs->max_th,
1.0 * fs->max_p / (double)(1 << SCALE_RED));
if (fs->flags & DN_IS_ECN)
-   strncat(red, " (ecn)", 6);
+   strlcat(red, " (ecn)", sizeof(red));
 #ifdef NEW_AQM
/* get AQM parameters */
} else if (fs->flags & DN_IS_AQM) {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r355759 - in head: include sys/sys

2019-12-14 Thread Xin Li via svn-src-all


On 2019-12-14 13:52, Conrad Meyer wrote:
> Author: cem
> Date: Sat Dec 14 21:52:49 2019
> New Revision: 355759
> URL: https://svnweb.freebsd.org/changeset/base/355759
> 
> Log:
>   cdefs: Add __deprecated(message) function attribute macro

This conflicts with Linux kernel and breaks DRM.  Please use a different
name.

Cheers,



signature.asc
Description: OpenPGP digital signature


svn commit: r355749 - stable/11/libexec/save-entropy

2019-12-14 Thread Xin LI
Author: delphij
Date: Sat Dec 14 09:54:30 2019
New Revision: 355749
URL: https://svnweb.freebsd.org/changeset/base/355749

Log:
  MFC r355247: Reduce disk write load in /usr/libexec/save-entropy.

Modified:
  stable/11/libexec/save-entropy/save-entropy.sh
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/libexec/save-entropy/save-entropy.sh
==
--- stable/11/libexec/save-entropy/save-entropy.sh  Sat Dec 14 09:49:36 
2019(r355748)
+++ stable/11/libexec/save-entropy/save-entropy.sh  Sat Dec 14 09:54:30 
2019(r355749)
@@ -69,24 +69,61 @@ cd "${entropy_dir}" || {
 
 for f in saved-entropy.*; do
case "${f}" in saved-entropy.\*) continue ;; esac   # No files match
-   [ ${f#saved-entropy\.} -ge ${entropy_save_num} ] && unlink ${f}
+   [ ${f#saved-entropy\.} -gt ${entropy_save_num} ] && unlink ${f}
 done
 
-umask 377
+umask 177
 
-n=$(( ${entropy_save_num} - 1 ))
-while [ ${n} -ge 1 ]; do
-   if [ -f "saved-entropy.${n}" ]; then
-   mv "saved-entropy.${n}" "saved-entropy.$(( ${n} + 1 ))"
-   elif [ -e "saved-entropy.${n}" -o -L "saved-entropy.${n}" ]; then
+# Scan slots [1..$entropy_save_num), picking an empty slot or the oldest
+# existing file if no empty slot was available.
+#
+# 1. Find out the first regular file or empty slot (and its serial number)
+#
+n=1
+while [ ${n} -le ${entropy_save_num} ]; do
+   save_file="saved-entropy.${n}"
+   if [ ! -e "${save_file}" -o -f "${save_file}" ]; then
+   break
+   else
logger -is -t "$0" \
-   "${entropy_dir}/saved-entropy.${n}" is not a regular file, and so \
-   it will not be rotated. Entropy file rotation is aborted.
-   exit 1
+   "${save_file}" is not a regular file, skipped.
fi
-   n=$(( ${n} - 1 ))
+   n=$(( ${n} + 1 ))
 done
+#
+# 2. Start from (serial number + 1), and check if the slot is empty
+#or is an older regular file, update save_file pointer in either
+#case, and break early if we found an empty slot.
+#
+if [ -f ${save_file} ]; then
+   n=$(( ${n} + 1 ))
+   while [ ${n} -le ${entropy_save_num} ]; do
+   next_file=saved-entropy.${n}
+   if [ -f "${next_file}" ]; then
+   [ "${next_file}" -ot "${save_file}" ] && \
+   save_file="${next_file}"
+   elif [ ! -e "${next_file}" ]; then
+   save_file="${next_file}"
+   break
+   else
+   logger -is -t "$0" \
+   "${next_file}" is not a regular file, skipped.
+   fi
+   n=$(( ${n} + 1 ))
+   done
+fi
+#
+# 3. Check if the pointer we have in hand is really a regular file or
+#an empty slot, and bail out as that means there is no available slot.
+#
+if [ -e "${save_file}" -a ! -f "${save_file}" ]; then
+   logger -is -t "$0" \
+   No available slot in "${entropy_dir}", save entropy is aborted.
+   exit 1
+fi
 
-dd if=/dev/random of=saved-entropy.1 bs=${entropy_save_sz} count=1 2>/dev/null
+# Save entropy to the selected slot.
+chmod 600 "${save_file}" 2>/dev/null || :
+dd if=/dev/random of="${save_file}" bs=${entropy_save_sz} count=1 2>/dev/null
 
 exit 0
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r355748 - in stable/12/libexec: rc/rc.d save-entropy

2019-12-14 Thread Xin LI
Author: delphij
Date: Sat Dec 14 09:49:36 2019
New Revision: 355748
URL: https://svnweb.freebsd.org/changeset/base/355748

Log:
  MFC r345744, r348122, r355247
  
  r345744: random(4): Attempt to persist entropy promptly
  r348122: save-entropy(8), rc.d/random: Set nodump flag
  r355247: Reduce disk write load in /usr/libexec/save-entropy.

Modified:
  stable/12/libexec/rc/rc.d/random
  stable/12/libexec/save-entropy/save-entropy.sh
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/libexec/rc/rc.d/random
==
--- stable/12/libexec/rc/rc.d/randomSat Dec 14 08:28:10 2019
(r355747)
+++ stable/12/libexec/rc/rc.d/randomSat Dec 14 09:49:36 2019
(r355748)
@@ -25,7 +25,9 @@ save_dev_random()
for f ; do
debug "saving entropy to $f"
dd if=/dev/random of="$f" bs=4096 count=1 status=none &&
-   chmod 600 "$f"
+   ( chflags nodump "$f" 2>/dev/null || : ) &&
+   chmod 600 "$f" &&
+   fsync "$f" "$(dirname "$f")"
done
umask ${oumask}
 }
@@ -98,7 +100,7 @@ random_stop()
[Nn][Oo])
;;
*)
-   echo -n 'Writing entropy file:'
+   echo -n 'Writing entropy file: '
rm -f ${entropy_file} 2> /dev/null
oumask=`umask`
umask 077
@@ -117,9 +119,7 @@ random_stop()
warn 'write failed (read-only fs?)'
;;
*)
-   dd if=/dev/random of=${entropy_file_confirmed} \
-   bs=4096 count=1 2> /dev/null ||
-   warn 'write failed (unwriteable file or full fs?)'
+   save_dev_random "${entropy_file_confirmed}"
echo '.'
;;
esac
@@ -130,7 +130,7 @@ random_stop()
[Nn][Oo])
;;
*)
-   echo -n 'Writing early boot entropy file:'
+   echo -n 'Writing early boot entropy file: '
rm -f ${entropy_boot_file} 2> /dev/null
oumask=`umask`
umask 077
@@ -142,9 +142,7 @@ random_stop()
warn 'write failed (read-only fs?)'
;;
*)
-   dd if=/dev/random of=${entropy_boot_file_confirmed} \
-   bs=4096 count=1 2> /dev/null ||
-   warn 'write failed (unwriteable file or full fs?)'
+   save_dev_random "${entropy_boot_file_confirmed}"
echo '.'
;;
esac

Modified: stable/12/libexec/save-entropy/save-entropy.sh
==
--- stable/12/libexec/save-entropy/save-entropy.sh  Sat Dec 14 08:28:10 
2019(r355747)
+++ stable/12/libexec/save-entropy/save-entropy.sh  Sat Dec 14 09:49:36 
2019(r355748)
@@ -71,24 +71,63 @@ cd "${entropy_dir}" || {
 
 for f in saved-entropy.*; do
case "${f}" in saved-entropy.\*) continue ;; esac   # No files match
-   [ ${f#saved-entropy\.} -ge ${entropy_save_num} ] && unlink ${f}
+   [ ${f#saved-entropy\.} -gt ${entropy_save_num} ] && unlink ${f}
 done
 
-umask 377
+umask 177
 
-n=$(( ${entropy_save_num} - 1 ))
-while [ ${n} -ge 1 ]; do
-   if [ -f "saved-entropy.${n}" ]; then
-   mv "saved-entropy.${n}" "saved-entropy.$(( ${n} + 1 ))"
-   elif [ -e "saved-entropy.${n}" -o -L "saved-entropy.${n}" ]; then
+# Scan slots [1..$entropy_save_num), picking an empty slot or the oldest
+# existing file if no empty slot was available.
+#
+# 1. Find out the first regular file or empty slot (and its serial number)
+#
+n=1
+while [ ${n} -le ${entropy_save_num} ]; do
+   save_file="saved-entropy.${n}"
+   if [ ! -e "${save_file}" -o -f "${save_file}" ]; then
+   break
+   else
logger -is -t "$0" \
-   "${entropy_dir}/saved-entropy.${n}" is not a regular file, and so \
-   it will not be rotated. Entropy file rotation is aborted.
-   exit 1
+   "${save_file}" is not a regular file, skipped.
fi
-   n=$(( ${n} - 1 ))
+   n=$(( ${n} + 1 ))
 done
+#
+# 2. Start from (serial number + 1), and check if the slot is empty
+#or is an older regular file, update save_file pointer in either
+#case, and break early if we found an empty slot.
+#
+if [ -f ${save_file} ]; then
+   n=$(( ${n} + 1 ))
+   while [ ${n} -le ${entropy_save_num} ]; do
+   next_file=saved-entropy.${n}
+   if [ -f "${next_file}" ]; then
+   [ "${next_file}" -ot "${save_file}" ] && \
+   save_file="${next_file}"
+   elif [

svn commit: r355604 - in stable/11: contrib/expat contrib/expat/doc contrib/expat/examples contrib/expat/lib contrib/expat/tests contrib/expat/tests/benchmark contrib/expat/xmlwf lib/libexpat

2019-12-10 Thread Xin LI
Author: delphij
Date: Wed Dec 11 06:34:48 2019
New Revision: 355604
URL: https://svnweb.freebsd.org/changeset/base/355604

Log:
  MFC r340127,340133,355085: libbsdxml (expat) 2.2.9.

Added:
  stable/11/contrib/expat/AUTHORS
 - copied unchanged from r340127, head/contrib/expat/AUTHORS
  stable/11/contrib/expat/Makefile.am
 - copied, changed from r340127, head/contrib/expat/Makefile.am
  stable/11/contrib/expat/README.md
 - copied, changed from r340127, head/contrib/expat/README.md
  stable/11/contrib/expat/doc/Makefile.am
 - copied, changed from r340127, head/contrib/expat/doc/Makefile.am
  stable/11/contrib/expat/doc/Makefile.in
 - copied, changed from r340127, head/contrib/expat/doc/Makefile.in
  stable/11/contrib/expat/examples/Makefile.am
 - copied unchanged from r340127, head/contrib/expat/examples/Makefile.am
  stable/11/contrib/expat/examples/Makefile.in
 - copied, changed from r340127, head/contrib/expat/examples/Makefile.in
  stable/11/contrib/expat/fix-xmltest-log.sh
 - copied unchanged from r355085, head/contrib/expat/fix-xmltest-log.sh
  stable/11/contrib/expat/lib/Makefile.am
 - copied, changed from r340127, head/contrib/expat/lib/Makefile.am
  stable/11/contrib/expat/lib/Makefile.in
 - copied, changed from r340127, head/contrib/expat/lib/Makefile.in
  stable/11/contrib/expat/lib/loadlibrary.c
 - copied unchanged from r340127, head/contrib/expat/lib/loadlibrary.c
  stable/11/contrib/expat/lib/siphash.h
 - copied, changed from r340127, head/contrib/expat/lib/siphash.h
  stable/11/contrib/expat/run.sh.in
 - copied unchanged from r340127, head/contrib/expat/run.sh.in
  stable/11/contrib/expat/test-driver-wrapper.sh
 - copied, changed from r340127, head/contrib/expat/test-driver-wrapper.sh
  stable/11/contrib/expat/tests/Makefile.am
 - copied unchanged from r340127, head/contrib/expat/tests/Makefile.am
  stable/11/contrib/expat/tests/Makefile.in
 - copied, changed from r340127, head/contrib/expat/tests/Makefile.in
  stable/11/contrib/expat/tests/benchmark/Makefile.am
 - copied unchanged from r340127, 
head/contrib/expat/tests/benchmark/Makefile.am
  stable/11/contrib/expat/tests/benchmark/Makefile.in
 - copied, changed from r340127, 
head/contrib/expat/tests/benchmark/Makefile.in
  stable/11/contrib/expat/tests/benchmark/benchmark.sln
 - copied unchanged from r340127, 
head/contrib/expat/tests/benchmark/benchmark.sln
  stable/11/contrib/expat/tests/memcheck.c
 - copied, changed from r340127, head/contrib/expat/tests/memcheck.c
  stable/11/contrib/expat/tests/memcheck.h
 - copied, changed from r340127, head/contrib/expat/tests/memcheck.h
  stable/11/contrib/expat/tests/runtests.sln
 - copied unchanged from r340127, head/contrib/expat/tests/runtests.sln
  stable/11/contrib/expat/tests/structdata.c
 - copied, changed from r340127, head/contrib/expat/tests/structdata.c
  stable/11/contrib/expat/tests/structdata.h
 - copied, changed from r340127, head/contrib/expat/tests/structdata.h
  stable/11/contrib/expat/tests/udiffer.py
 - copied unchanged from r340127, head/contrib/expat/tests/udiffer.py
  stable/11/contrib/expat/tests/xmltest.log.expected
 - copied unchanged from r340127, 
head/contrib/expat/tests/xmltest.log.expected
  stable/11/contrib/expat/xmlwf/Makefile.am
 - copied, changed from r340127, head/contrib/expat/xmlwf/Makefile.am
  stable/11/contrib/expat/xmlwf/Makefile.in
 - copied, changed from r340127, head/contrib/expat/xmlwf/Makefile.in
  stable/11/contrib/expat/xmlwf/xmlwf_helpgen.py
 - copied unchanged from r355085, head/contrib/expat/xmlwf/xmlwf_helpgen.py
  stable/11/contrib/expat/xmlwf/xmlwf_helpgen.sh
 - copied unchanged from r355085, head/contrib/expat/xmlwf/xmlwf_helpgen.sh
Deleted:
  stable/11/contrib/expat/MANIFEST
  stable/11/contrib/expat/README
Modified:
  stable/11/contrib/expat/COPYING   (contents, props changed)
  stable/11/contrib/expat/Changes   (contents, props changed)
  stable/11/contrib/expat/FREEBSD-Xlist   (contents, props changed)
  stable/11/contrib/expat/Makefile.in   (contents, props changed)
  stable/11/contrib/expat/configure.ac   (contents, props changed)
  stable/11/contrib/expat/doc/reference.html   (contents, props changed)
  stable/11/contrib/expat/doc/xmlwf.1   (contents, props changed)
  stable/11/contrib/expat/doc/xmlwf.xml   (contents, props changed)
  stable/11/contrib/expat/examples/elements.c   (contents, props changed)
  stable/11/contrib/expat/examples/outline.c   (contents, props changed)
  stable/11/contrib/expat/expat_config.h.in   (contents, props changed)
  stable/11/contrib/expat/lib/ascii.h   (contents, props changed)
  stable/11/contrib/expat/lib/asciitab.h   (contents, props changed)
  stable/11/contrib/expat/lib/expat.h   (contents, props changed)
  stable/11/contrib/expat/lib/expat_external.h   (contents, props changed)
  stable/11/contrib/expat/lib/iasciitab.h   (contents, props changed)
  stable/11/contrib/expat/lib/

svn commit: r355603 - in stable/12: contrib/expat contrib/expat/doc contrib/expat/examples contrib/expat/lib contrib/expat/tests contrib/expat/tests/benchmark contrib/expat/xmlwf lib/libexpat

2019-12-10 Thread Xin LI
Author: delphij
Date: Wed Dec 11 06:30:26 2019
New Revision: 355603
URL: https://svnweb.freebsd.org/changeset/base/355603

Log:
  MFC r340127,340133,355085: libbsdxml (expat) 2.2.9.

Added:
  stable/12/contrib/expat/AUTHORS
 - copied unchanged from r340127, head/contrib/expat/AUTHORS
  stable/12/contrib/expat/Makefile.am
 - copied, changed from r340127, head/contrib/expat/Makefile.am
  stable/12/contrib/expat/README.md
 - copied, changed from r340127, head/contrib/expat/README.md
  stable/12/contrib/expat/doc/Makefile.am
 - copied, changed from r340127, head/contrib/expat/doc/Makefile.am
  stable/12/contrib/expat/doc/Makefile.in
 - copied, changed from r340127, head/contrib/expat/doc/Makefile.in
  stable/12/contrib/expat/examples/Makefile.am
 - copied unchanged from r340127, head/contrib/expat/examples/Makefile.am
  stable/12/contrib/expat/examples/Makefile.in
 - copied, changed from r340127, head/contrib/expat/examples/Makefile.in
  stable/12/contrib/expat/fix-xmltest-log.sh
 - copied unchanged from r355085, head/contrib/expat/fix-xmltest-log.sh
  stable/12/contrib/expat/lib/Makefile.am
 - copied, changed from r340127, head/contrib/expat/lib/Makefile.am
  stable/12/contrib/expat/lib/Makefile.in
 - copied, changed from r340127, head/contrib/expat/lib/Makefile.in
  stable/12/contrib/expat/lib/loadlibrary.c
 - copied unchanged from r340127, head/contrib/expat/lib/loadlibrary.c
  stable/12/contrib/expat/lib/siphash.h
 - copied, changed from r340127, head/contrib/expat/lib/siphash.h
  stable/12/contrib/expat/run.sh.in
 - copied unchanged from r340127, head/contrib/expat/run.sh.in
  stable/12/contrib/expat/test-driver-wrapper.sh
 - copied, changed from r340127, head/contrib/expat/test-driver-wrapper.sh
  stable/12/contrib/expat/tests/Makefile.am
 - copied unchanged from r340127, head/contrib/expat/tests/Makefile.am
  stable/12/contrib/expat/tests/Makefile.in
 - copied, changed from r340127, head/contrib/expat/tests/Makefile.in
  stable/12/contrib/expat/tests/benchmark/Makefile.am
 - copied unchanged from r340127, 
head/contrib/expat/tests/benchmark/Makefile.am
  stable/12/contrib/expat/tests/benchmark/Makefile.in
 - copied, changed from r340127, 
head/contrib/expat/tests/benchmark/Makefile.in
  stable/12/contrib/expat/tests/benchmark/benchmark.sln
 - copied unchanged from r340127, 
head/contrib/expat/tests/benchmark/benchmark.sln
  stable/12/contrib/expat/tests/memcheck.c
 - copied, changed from r340127, head/contrib/expat/tests/memcheck.c
  stable/12/contrib/expat/tests/memcheck.h
 - copied, changed from r340127, head/contrib/expat/tests/memcheck.h
  stable/12/contrib/expat/tests/runtests.sln
 - copied unchanged from r340127, head/contrib/expat/tests/runtests.sln
  stable/12/contrib/expat/tests/structdata.c
 - copied, changed from r340127, head/contrib/expat/tests/structdata.c
  stable/12/contrib/expat/tests/structdata.h
 - copied, changed from r340127, head/contrib/expat/tests/structdata.h
  stable/12/contrib/expat/tests/udiffer.py
 - copied unchanged from r340127, head/contrib/expat/tests/udiffer.py
  stable/12/contrib/expat/tests/xmltest.log.expected
 - copied unchanged from r340127, 
head/contrib/expat/tests/xmltest.log.expected
  stable/12/contrib/expat/xmlwf/Makefile.am
 - copied, changed from r340127, head/contrib/expat/xmlwf/Makefile.am
  stable/12/contrib/expat/xmlwf/Makefile.in
 - copied, changed from r340127, head/contrib/expat/xmlwf/Makefile.in
  stable/12/contrib/expat/xmlwf/xmlwf_helpgen.py
 - copied unchanged from r355085, head/contrib/expat/xmlwf/xmlwf_helpgen.py
  stable/12/contrib/expat/xmlwf/xmlwf_helpgen.sh
 - copied unchanged from r355085, head/contrib/expat/xmlwf/xmlwf_helpgen.sh
Deleted:
  stable/12/contrib/expat/MANIFEST
  stable/12/contrib/expat/README
Modified:
  stable/12/contrib/expat/COPYING   (contents, props changed)
  stable/12/contrib/expat/Changes   (contents, props changed)
  stable/12/contrib/expat/FREEBSD-Xlist   (contents, props changed)
  stable/12/contrib/expat/Makefile.in   (contents, props changed)
  stable/12/contrib/expat/configure.ac   (contents, props changed)
  stable/12/contrib/expat/doc/reference.html   (contents, props changed)
  stable/12/contrib/expat/doc/xmlwf.1   (contents, props changed)
  stable/12/contrib/expat/doc/xmlwf.xml   (contents, props changed)
  stable/12/contrib/expat/examples/elements.c   (contents, props changed)
  stable/12/contrib/expat/examples/outline.c   (contents, props changed)
  stable/12/contrib/expat/expat_config.h.in   (contents, props changed)
  stable/12/contrib/expat/lib/ascii.h   (contents, props changed)
  stable/12/contrib/expat/lib/asciitab.h   (contents, props changed)
  stable/12/contrib/expat/lib/expat.h   (contents, props changed)
  stable/12/contrib/expat/lib/expat_external.h   (contents, props changed)
  stable/12/contrib/expat/lib/iasciitab.h   (contents, props changed)
  stable/12/contrib/expat/lib/

svn commit: r355513 - head/sbin/newfs_msdos

2019-12-07 Thread Xin LI
Author: delphij
Date: Sun Dec  8 01:20:37 2019
New Revision: 355513
URL: https://svnweb.freebsd.org/changeset/base/355513

Log:
  Fix a couple of minor issues with newfs_msdos:
  
   - Do not unnecessarily strdup().
   - Check return value of getdiskinfo(), if it failed, bail out.
  
  Reviewed by:  imp
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D22729

Modified:
  head/sbin/newfs_msdos/mkfs_msdos.c
  head/sbin/newfs_msdos/newfs_msdos.c

Modified: head/sbin/newfs_msdos/mkfs_msdos.c
==
--- head/sbin/newfs_msdos/mkfs_msdos.c  Sun Dec  8 01:17:38 2019
(r355512)
+++ head/sbin/newfs_msdos/mkfs_msdos.c  Sun Dec  8 01:20:37 2019
(r355513)
@@ -318,7 +318,8 @@ mkfs_msdos(const char *fname, const char *dtype, const
bpb.bpbHiddenSecs = o.hidden_sectors;
 if (!(o.floppy || (o.drive_heads && o.sectors_per_track &&
o.bytes_per_sector && o.size && o.hidden_sectors_set))) {
-   getdiskinfo(fd, fname, dtype, o.hidden_sectors_set, &bpb);
+   if (getdiskinfo(fd, fname, dtype, o.hidden_sectors_set, &bpb) == -1)
+   goto done;
bpb.bpbHugeSectors -= (o.offset / bpb.bpbBytesPerSec);
if (bpb.bpbSecPerClust == 0) {  /* set defaults */
if (bpb.bpbHugeSectors <= 6000) /* about 3MB -> 512 bytes */
@@ -423,10 +424,7 @@ mkfs_msdos(const char *fname, const char *dtype, const
bname = o.bootstrap;
if (!strchr(bname, '/')) {
snprintf(buf, sizeof(buf), "/boot/%s", bname);
-   if (!(bname = strdup(buf))) {
-   warn(NULL);
-   goto done;
-   }
+   bname = buf;
}
if ((fd1 = open(bname, O_RDONLY)) == -1 || fstat(fd1, &sb)) {
warn("%s", bname);

Modified: head/sbin/newfs_msdos/newfs_msdos.c
==
--- head/sbin/newfs_msdos/newfs_msdos.c Sun Dec  8 01:17:38 2019
(r355512)
+++ head/sbin/newfs_msdos/newfs_msdos.c Sun Dec  8 01:20:37 2019
(r355513)
@@ -185,8 +185,7 @@ main(int argc, char *argv[])
 fname = *argv++;
 if (!o.create_size && !strchr(fname, '/')) {
snprintf(buf, sizeof(buf), "%s%s", _PATH_DEV, fname);
-   if (!(fname = strdup(buf)))
-   err(1, NULL);
+   fname = buf;
 }
 dtype = *argv;
 exit(!!mkfs_msdos(fname, dtype, &o));
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r355504 - in stable/11: contrib/less usr.bin/less

2019-12-07 Thread Xin LI
Author: delphij
Date: Sat Dec  7 19:05:48 2019
New Revision: 355504
URL: https://svnweb.freebsd.org/changeset/base/355504

Log:
  MFC r349549: MFV r349535: less v551.
  
  Relnotes: yes

Modified:
  stable/11/contrib/less/LICENSE
  stable/11/contrib/less/NEWS
  stable/11/contrib/less/README
  stable/11/contrib/less/brac.c
  stable/11/contrib/less/ch.c
  stable/11/contrib/less/charset.c
  stable/11/contrib/less/charset.h
  stable/11/contrib/less/cmd.h
  stable/11/contrib/less/cmdbuf.c
  stable/11/contrib/less/command.c
  stable/11/contrib/less/compose.uni
  stable/11/contrib/less/cvt.c
  stable/11/contrib/less/decode.c
  stable/11/contrib/less/edit.c
  stable/11/contrib/less/filename.c
  stable/11/contrib/less/fmt.uni
  stable/11/contrib/less/forwback.c
  stable/11/contrib/less/funcs.h
  stable/11/contrib/less/help.c
  stable/11/contrib/less/ifile.c
  stable/11/contrib/less/input.c
  stable/11/contrib/less/jump.c
  stable/11/contrib/less/less.h
  stable/11/contrib/less/less.hlp
  stable/11/contrib/less/less.nro
  stable/11/contrib/less/lessecho.c
  stable/11/contrib/less/lessecho.nro
  stable/11/contrib/less/lesskey.c
  stable/11/contrib/less/lesskey.h
  stable/11/contrib/less/lesskey.nro
  stable/11/contrib/less/lglob.h
  stable/11/contrib/less/line.c
  stable/11/contrib/less/linenum.c
  stable/11/contrib/less/lsystem.c
  stable/11/contrib/less/main.c
  stable/11/contrib/less/mark.c
  stable/11/contrib/less/mkutable
  stable/11/contrib/less/optfunc.c
  stable/11/contrib/less/option.c
  stable/11/contrib/less/option.h
  stable/11/contrib/less/opttbl.c
  stable/11/contrib/less/os.c
  stable/11/contrib/less/output.c
  stable/11/contrib/less/pattern.c
  stable/11/contrib/less/pattern.h
  stable/11/contrib/less/pckeys.h
  stable/11/contrib/less/position.c
  stable/11/contrib/less/position.h
  stable/11/contrib/less/prompt.c
  stable/11/contrib/less/screen.c
  stable/11/contrib/less/scrsize.c
  stable/11/contrib/less/search.c
  stable/11/contrib/less/signal.c
  stable/11/contrib/less/tags.c
  stable/11/contrib/less/ttyin.c
  stable/11/contrib/less/ubin.uni
  stable/11/contrib/less/version.c
  stable/11/contrib/less/wide.uni
  stable/11/usr.bin/less/defines.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/contrib/less/LICENSE
==
--- stable/11/contrib/less/LICENSE  Sat Dec  7 19:02:09 2019
(r355503)
+++ stable/11/contrib/less/LICENSE  Sat Dec  7 19:05:48 2019
(r355504)
@@ -2,7 +2,7 @@
   
 
 Less
-Copyright (C) 1984-2016  Mark Nudelman
+Copyright (C) 1984-2018  Mark Nudelman
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions

Modified: stable/11/contrib/less/NEWS
==
--- stable/11/contrib/less/NEWS Sat Dec  7 19:02:09 2019(r355503)
+++ stable/11/contrib/less/NEWS Sat Dec  7 19:05:48 2019(r355504)
@@ -11,6 +11,38 @@
 
 ==
 
+   Major changes between "less" versions 530 and 551
+
+* Add --mouse option.
+
+* Add --wheel-lines option.
+
+* Add --no-histdups option.
+
+* Add --save-marks option.
+
+* Support PCRE2 regular expression library.
+
+* Redraw screen on SIGWINCH even if screen size doesn't change.
+
+* Shell-escape filenames in history so they can be used again.
+
+* Ring bell if user enters invalid long option name.
+
+* Use PCRE_UTF8 flag for pcre regular expressions when in UTF-8 mode.
+
+* Windows: use wide-char string to set console title.
+
+* Don't count lines in initial screen if using -X with -F.
+
+* Support mingw build system.
+
+* Fix bug in v command on empty file.
+
+* Fix bug in v command when filename contains shell metacharacters.
+
+==
+
Major changes between "less" versions 487 and 530
 
 * Don't output terminal init sequence if using -F and file fits on one screen.

Modified: stable/11/contrib/less/README
==
--- stable/11/contrib/less/README   Sat Dec  7 19:02:09 2019
(r355503)
+++ stable/11/contrib/less/README   Sat Dec  7 19:05:48 2019
(r355504)
@@ -7,9 +7,9 @@
 **
 **
 
-Less, version 530
+Less, version 551
 
-This is the distribution of less, version 530, released 05 Dec 2017.
+This is the distribution of less, version 551, released 11 Jun 2019.
 This program is part of the GNU project (http://www.gnu.org).
 
 This program is free software.  You may redistribute it and/or
@@ -56,6 +56,7 @@ IN

svn commit: r355503 - in stable/12: contrib/less usr.bin/less

2019-12-07 Thread Xin LI
Author: delphij
Date: Sat Dec  7 19:02:09 2019
New Revision: 355503
URL: https://svnweb.freebsd.org/changeset/base/355503

Log:
  MFC r349549: MFV r349535: less v551.
  
  Relnotes: yes

Modified:
  stable/12/contrib/less/LICENSE
  stable/12/contrib/less/NEWS
  stable/12/contrib/less/README
  stable/12/contrib/less/brac.c
  stable/12/contrib/less/ch.c
  stable/12/contrib/less/charset.c
  stable/12/contrib/less/charset.h
  stable/12/contrib/less/cmd.h
  stable/12/contrib/less/cmdbuf.c
  stable/12/contrib/less/command.c
  stable/12/contrib/less/compose.uni
  stable/12/contrib/less/cvt.c
  stable/12/contrib/less/decode.c
  stable/12/contrib/less/edit.c
  stable/12/contrib/less/filename.c
  stable/12/contrib/less/fmt.uni
  stable/12/contrib/less/forwback.c
  stable/12/contrib/less/funcs.h
  stable/12/contrib/less/help.c
  stable/12/contrib/less/ifile.c
  stable/12/contrib/less/input.c
  stable/12/contrib/less/jump.c
  stable/12/contrib/less/less.h
  stable/12/contrib/less/less.hlp
  stable/12/contrib/less/less.nro
  stable/12/contrib/less/lessecho.c
  stable/12/contrib/less/lessecho.nro
  stable/12/contrib/less/lesskey.c
  stable/12/contrib/less/lesskey.h
  stable/12/contrib/less/lesskey.nro
  stable/12/contrib/less/lglob.h
  stable/12/contrib/less/line.c
  stable/12/contrib/less/linenum.c
  stable/12/contrib/less/lsystem.c
  stable/12/contrib/less/main.c
  stable/12/contrib/less/mark.c
  stable/12/contrib/less/mkutable
  stable/12/contrib/less/optfunc.c
  stable/12/contrib/less/option.c
  stable/12/contrib/less/option.h
  stable/12/contrib/less/opttbl.c
  stable/12/contrib/less/os.c
  stable/12/contrib/less/output.c
  stable/12/contrib/less/pattern.c
  stable/12/contrib/less/pattern.h
  stable/12/contrib/less/pckeys.h
  stable/12/contrib/less/position.c
  stable/12/contrib/less/position.h
  stable/12/contrib/less/prompt.c
  stable/12/contrib/less/screen.c
  stable/12/contrib/less/scrsize.c
  stable/12/contrib/less/search.c
  stable/12/contrib/less/signal.c
  stable/12/contrib/less/tags.c
  stable/12/contrib/less/ttyin.c
  stable/12/contrib/less/ubin.uni
  stable/12/contrib/less/version.c
  stable/12/contrib/less/wide.uni
  stable/12/usr.bin/less/defines.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/contrib/less/LICENSE
==
--- stable/12/contrib/less/LICENSE  Sat Dec  7 18:40:46 2019
(r355502)
+++ stable/12/contrib/less/LICENSE  Sat Dec  7 19:02:09 2019
(r355503)
@@ -2,7 +2,7 @@
   
 
 Less
-Copyright (C) 1984-2016  Mark Nudelman
+Copyright (C) 1984-2018  Mark Nudelman
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions

Modified: stable/12/contrib/less/NEWS
==
--- stable/12/contrib/less/NEWS Sat Dec  7 18:40:46 2019(r355502)
+++ stable/12/contrib/less/NEWS Sat Dec  7 19:02:09 2019(r355503)
@@ -11,6 +11,38 @@
 
 ==
 
+   Major changes between "less" versions 530 and 551
+
+* Add --mouse option.
+
+* Add --wheel-lines option.
+
+* Add --no-histdups option.
+
+* Add --save-marks option.
+
+* Support PCRE2 regular expression library.
+
+* Redraw screen on SIGWINCH even if screen size doesn't change.
+
+* Shell-escape filenames in history so they can be used again.
+
+* Ring bell if user enters invalid long option name.
+
+* Use PCRE_UTF8 flag for pcre regular expressions when in UTF-8 mode.
+
+* Windows: use wide-char string to set console title.
+
+* Don't count lines in initial screen if using -X with -F.
+
+* Support mingw build system.
+
+* Fix bug in v command on empty file.
+
+* Fix bug in v command when filename contains shell metacharacters.
+
+==
+
Major changes between "less" versions 487 and 530
 
 * Don't output terminal init sequence if using -F and file fits on one screen.

Modified: stable/12/contrib/less/README
==
--- stable/12/contrib/less/README   Sat Dec  7 18:40:46 2019
(r355502)
+++ stable/12/contrib/less/README   Sat Dec  7 19:02:09 2019
(r355503)
@@ -7,9 +7,9 @@
 **
 **
 
-Less, version 530
+Less, version 551
 
-This is the distribution of less, version 530, released 05 Dec 2017.
+This is the distribution of less, version 551, released 11 Jun 2019.
 This program is part of the GNU project (http://www.gnu.org).
 
 This program is free software.  You may redistribute it and/or
@@ -56,6 +56,7 @@ IN

Re: svn commit: r355318 - head/sbin/newfs_msdos

2019-12-04 Thread Xin Li
On 12/3/19 14:02, Conrad Meyer wrote:
> Hi Xin Li,
> 
> Is there a reason to prefer exit() over returning from main?  I have

No, this should be case-by-case (and also assumes you are using C and
not C++).

The two are actually subtly different (return means teardown main's
stack first, then implicitly call exit from C runtime, while exit()
would terminate immediately).

If the command is meant to be used as a built-in module of something
else, like the case of kill(1) builtin of sh(1), then one must not use
exit() and also need to pay special attention to not exit() implicitly,
because the caller will not fork() prior to calling the aliased main()
function for performance reasons.

For other cases, using exit() might be a good idea, because it's easier
to find the exit points especially if one is following sysexits(3)
values.  Another reason is that if one allocates memory in main but not
free them (these shouldn't be free'ed because the kernel would unmap all
pages upon exit), return would mean these memory would be leaked: these
are legitimate issues when main() would be called by someone else.  With
an explicit exit(), these memory are never leaked because stack frame of
main() remains valid before the final _exit(2) call.

> not surveyed the source tree, but I suspect most programs in base exit
> by returning from main rather than explicit exit(3).> Thanks,
> Conrad
> 
> On Mon, Dec 2, 2019 at 11:03 PM Xin LI  wrote:
>>
>> Author: delphij
>> Date: Tue Dec  3 07:03:25 2019
>> New Revision: 355318
>> URL: https://svnweb.freebsd.org/changeset/base/355318
>>
>> Log:
>>   Explicitly exit() instead of return in main().
>>
>>   MFC after:2 weeks
>>
>> Modified:
>>   head/sbin/newfs_msdos/newfs_msdos.c
>>
>> Modified: head/sbin/newfs_msdos/newfs_msdos.c
>> ==
>> --- head/sbin/newfs_msdos/newfs_msdos.c Tue Dec  3 07:01:28 2019
>> (r355317)
>> +++ head/sbin/newfs_msdos/newfs_msdos.c Tue Dec  3 07:03:25 2019
>> (r355318)
>> @@ -189,7 +189,7 @@ main(int argc, char *argv[])
>> err(1, NULL);
>>  }
>>  dtype = *argv;
>> -return !!mkfs_msdos(fname, dtype, &o);
>> +exit(!!mkfs_msdos(fname, dtype, &o));
>>  }
>>
>>  /*




signature.asc
Description: OpenPGP digital signature


svn commit: r355318 - head/sbin/newfs_msdos

2019-12-02 Thread Xin LI
Author: delphij
Date: Tue Dec  3 07:03:25 2019
New Revision: 355318
URL: https://svnweb.freebsd.org/changeset/base/355318

Log:
  Explicitly exit() instead of return in main().
  
  MFC after:2 weeks

Modified:
  head/sbin/newfs_msdos/newfs_msdos.c

Modified: head/sbin/newfs_msdos/newfs_msdos.c
==
--- head/sbin/newfs_msdos/newfs_msdos.c Tue Dec  3 07:01:28 2019
(r355317)
+++ head/sbin/newfs_msdos/newfs_msdos.c Tue Dec  3 07:03:25 2019
(r355318)
@@ -189,7 +189,7 @@ main(int argc, char *argv[])
err(1, NULL);
 }
 dtype = *argv;
-return !!mkfs_msdos(fname, dtype, &o);
+exit(!!mkfs_msdos(fname, dtype, &o));
 }
 
 /*
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r355317 - head/sbin/newfs_msdos

2019-12-02 Thread Xin LI
Author: delphij
Date: Tue Dec  3 07:01:28 2019
New Revision: 355317
URL: https://svnweb.freebsd.org/changeset/base/355317

Log:
  newfs_msdos: -A is incompatible with -r, not -o.
  
  PR:   242314
  Submitted by: Guy Yur 
  MFC after:2 weeks

Modified:
  head/sbin/newfs_msdos/newfs_msdos.c

Modified: head/sbin/newfs_msdos/newfs_msdos.c
==
--- head/sbin/newfs_msdos/newfs_msdos.c Tue Dec  3 02:30:52 2019
(r355316)
+++ head/sbin/newfs_msdos/newfs_msdos.c Tue Dec  3 07:01:28 2019
(r355317)
@@ -179,7 +179,7 @@ main(int argc, char *argv[])
 if (argc < 1 || argc > 2)
usage();
if (o.align) {
-   if (o.hidden_sectors_set)
+   if (o.reserved_sectors)
errx(1, "align (-A) is incompatible with -r");
}
 fname = *argv++;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r355260 - head/libexec/getty

2019-12-01 Thread Xin LI
Author: delphij
Date: Sun Dec  1 08:04:22 2019
New Revision: 355260
URL: https://svnweb.freebsd.org/changeset/base/355260

Log:
  Simplify code with strlcpy/strlcat.
  
  MFC after:2 weeks

Modified:
  head/libexec/getty/main.c
  head/libexec/getty/subr.c

Modified: head/libexec/getty/main.c
==
--- head/libexec/getty/main.c   Sun Dec  1 07:44:21 2019(r355259)
+++ head/libexec/getty/main.c   Sun Dec  1 08:04:22 2019(r355260)
@@ -97,7 +97,6 @@ static int crmod, digit, lower, upper;
 
 char   hostname[MAXHOSTNAMELEN];
 static charname[MAXLOGNAME*3];
-static chardev[] = _PATH_DEV;
 static charttyn[32];
 
 #defineOBUFSIZ 128
@@ -218,8 +217,8 @@ main(int argc, char *argv[])
if (argc <= 2 || strcmp(argv[2], "-") == 0)
strcpy(ttyn, ttyname(STDIN_FILENO));
else {
-   strcpy(ttyn, dev);
-   strncat(ttyn, argv[2], sizeof(ttyn)-sizeof(dev));
+   strcpy(ttyn, _PATH_DEV);
+   strlcat(ttyn, argv[2], sizeof(ttyn));
if (strcmp(argv[0], "+") != 0) {
chown(ttyn, 0, 0);
chmod(ttyn, 0600);

Modified: head/libexec/getty/subr.c
==
--- head/libexec/getty/subr.c   Sun Dec  1 07:44:21 2019(r355259)
+++ head/libexec/getty/subr.c   Sun Dec  1 08:04:22 2019(r355260)
@@ -89,10 +89,8 @@ gettable(const char *name, char *buf)
l = 2;
else
l = strlen(sp->value) + 1;
-   if ((p = malloc(l)) != NULL) {
-   strncpy(p, sp->value, l);
-   p[l-1] = '\0';
-   }
+   if ((p = malloc(l)) != NULL)
+   strlcpy(p, sp->value, l);
/*
 * replace, even if NULL, else we'll
 * have problems with free()ing static mem
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r355247 - head/libexec/save-entropy

2019-11-30 Thread Xin LI
Author: delphij
Date: Sat Nov 30 20:06:53 2019
New Revision: 355247
URL: https://svnweb.freebsd.org/changeset/base/355247

Log:
  Reduce disk write load in /usr/libexec/save-entropy.
  
  Before this commit, the save-entropy script rotates entropy files
  like logs. This involves creating a new file that holds the entropy
  and renaming of all existing entropy files. However, the entropy
  data do not really need to be kept in a particular order, and
  replacing the oldest file is sufficient.
  
  This commit replaces the rotation with a scan in the
  [1..entropy_save_num] space that finds the first empty slot, or
  the slot of the oldest file, and writes entropy into that slot.
  
  This also fixes an issue that prevents save-entropy from saving
  any entropy when there is one non-regular file in any slot as a
  side effect.
  
  Based on an earlier patch from peterj@.
  
  PR:   134225
  Reported by:  peterj
  Reviewed by:  csprng (cem, markm)
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D22612

Modified:
  head/libexec/save-entropy/save-entropy.sh

Modified: head/libexec/save-entropy/save-entropy.sh
==
--- head/libexec/save-entropy/save-entropy.sh   Sat Nov 30 20:04:40 2019
(r355246)
+++ head/libexec/save-entropy/save-entropy.sh   Sat Nov 30 20:06:53 2019
(r355247)
@@ -71,26 +71,63 @@ cd "${entropy_dir}" || {
 
 for f in saved-entropy.*; do
case "${f}" in saved-entropy.\*) continue ;; esac   # No files match
-   [ ${f#saved-entropy\.} -ge ${entropy_save_num} ] && unlink ${f}
+   [ ${f#saved-entropy\.} -gt ${entropy_save_num} ] && unlink ${f}
 done
 
-umask 377
+umask 177
 
-n=$(( ${entropy_save_num} - 1 ))
-while [ ${n} -ge 1 ]; do
-   if [ -f "saved-entropy.${n}" ]; then
-   mv "saved-entropy.${n}" "saved-entropy.$(( ${n} + 1 ))"
-   elif [ -e "saved-entropy.${n}" -o -L "saved-entropy.${n}" ]; then
+# Scan slots [1..$entropy_save_num), picking an empty slot or the oldest
+# existing file if no empty slot was available.
+#
+# 1. Find out the first regular file or empty slot (and its serial number)
+#
+n=1
+while [ ${n} -le ${entropy_save_num} ]; do
+   save_file="saved-entropy.${n}"
+   if [ ! -e "${save_file}" -o -f "${save_file}" ]; then
+   break
+   else
logger -is -t "$0" \
-   "${entropy_dir}/saved-entropy.${n}" is not a regular file, and so \
-   it will not be rotated. Entropy file rotation is aborted.
-   exit 1
+   "${save_file}" is not a regular file, skipped.
fi
-   n=$(( ${n} - 1 ))
+   n=$(( ${n} + 1 ))
 done
+#
+# 2. Start from (serial number + 1), and check if the slot is empty
+#or is an older regular file, update save_file pointer in either
+#case, and break early if we found an empty slot.
+#
+if [ -f ${save_file} ]; then
+   n=$(( ${n} + 1 ))
+   while [ ${n} -le ${entropy_save_num} ]; do
+   next_file=saved-entropy.${n}
+   if [ -f "${next_file}" ]; then
+   [ "${next_file}" -ot "${save_file}" ] && \
+   save_file="${next_file}"
+   elif [ ! -e "${next_file}" ]; then
+   save_file="${next_file}"
+   break
+   else
+   logger -is -t "$0" \
+   "${next_file}" is not a regular file, skipped.
+   fi
+   n=$(( ${n} + 1 ))
+   done
+fi
+#
+# 3. Check if the pointer we have in hand is really a regular file or
+#an empty slot, and bail out as that means there is no available slot.
+#
+if [ -e "${save_file}" -a ! -f "${save_file}" ]; then
+   logger -is -t "$0" \
+   No available slot in "${entropy_dir}", save entropy is aborted.
+   exit 1
+fi
 
-dd if=/dev/random of=saved-entropy.1 bs=${entropy_save_sz} count=1 2>/dev/null
-chflags nodump saved-entropy.1 2>/dev/null || :
-fsync saved-entropy.1 "."
+# Save entropy to the selected slot.
+chmod 600 "${save_file}" 2>/dev/null || :
+dd if=/dev/random of="${save_file}" bs=${entropy_save_sz} count=1 2>/dev/null
+chflags nodump "${save_file}" 2>/dev/null || :
+fsync "${save_file}" "."
 
 exit 0
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r355223 - stable/12/lib/liblzma

2019-11-29 Thread Xin LI
Author: delphij
Date: Sat Nov 30 06:02:13 2019
New Revision: 355223
URL: https://svnweb.freebsd.org/changeset/base/355223

Log:
  MFC r342876: Enable use of Capsicum sandbox when there is only one
  input file (or the input is stdin) and we are not creating output
  file.
  
  Reported by:  Lasse Collin

Modified:
  stable/12/lib/liblzma/config.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/lib/liblzma/config.h
==
--- stable/12/lib/liblzma/config.h  Sat Nov 30 05:57:54 2019
(r355222)
+++ stable/12/lib/liblzma/config.h  Sat Nov 30 06:02:13 2019
(r355223)
@@ -26,7 +26,7 @@
 /* #undef HAVE_BYTESWAP_H */
 
 /* Define to 1 if Capsicum is available. */
-/* #undef HAVE_CAPSICUM */
+#define HAVE_CAPSICUM 1
 
 /* Define to 1 if the system has the type `CC_SHA256_CTX'. */
 /* #undef HAVE_CC_SHA256_CTX */
@@ -261,7 +261,7 @@
 /* #undef HAVE_SYS_BYTEORDER_H */
 
 /* Define to 1 if you have the  header file. */
-/* #undef HAVE_SYS_CAPSICUM_H */
+#define HAVE_SYS_CAPSICUM_H 1
 
 /* Define to 1 if you have the  header file. */
 #define HAVE_SYS_ENDIAN_H 1
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r355222 - head/sbin/ipfw

2019-11-29 Thread Xin LI
Author: delphij
Date: Sat Nov 30 05:57:54 2019
New Revision: 355222
URL: https://svnweb.freebsd.org/changeset/base/355222

Log:
  Use strlcat().
  
  MFC after:2 weeks

Modified:
  head/sbin/ipfw/dummynet.c

Modified: head/sbin/ipfw/dummynet.c
==
--- head/sbin/ipfw/dummynet.c   Sat Nov 30 05:43:24 2019(r355221)
+++ head/sbin/ipfw/dummynet.c   Sat Nov 30 05:57:54 2019(r355222)
@@ -497,7 +497,7 @@ print_flowset_parms(struct dn_fs *fs, char *prefix)
fs->max_th,
1.0 * fs->max_p / (double)(1 << SCALE_RED));
if (fs->flags & DN_IS_ECN)
-   strncat(red, " (ecn)", 6);
+   strlcat(red, " (ecn)", sizeof(red));
 #ifdef NEW_AQM
/* get AQM parameters */
} else if (fs->flags & DN_IS_AQM) {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r355221 - stable/12/sbin/fsck_msdosfs

2019-11-29 Thread Xin LI
Author: delphij
Date: Sat Nov 30 05:43:24 2019
New Revision: 355221
URL: https://svnweb.freebsd.org/changeset/base/355221

Log:
  MFC r345839, r345894, r345897, r345900-r345901, r345976, r346220, r348602, 
r348767, r348967, r349047-r349048, r351502, r351623, r352364
  
  r345839: Assert that q can't be NULL.  'empty' is always non-NULL when 
DIREMPTY
  r345894: Restore the ability of checking and fixing next free
  r345897: Restore lfcl when LOSTDIR's chain was corrupted and overwritten
  r345900: Implement checking of `.' and `..' entries of subdirectory.
  r345901: Fix build.
  r345976: Write string constant differently to improve readability.
  r346220: Don't cast result from malloc().
  r348602: Don't increment cl after increment.
  r348767: preen should work independently with alwaysyes and alwaysno.
  r348967: Avoid out of boundary access when checking invalid long filenames.
  r349047: Blankspace.  No actual code change.
  r349048: In ask(): override default option if any of 
alwaysyes/alwaysno/rdonly is
  r351502: Comment boot block checks and perform additional sanity checks:
  r351623: Remove unneeded blank line.  No functional change.
  r352364: Avoid mixing cluster numbers and sector numbers. Makes code more 
readable.

Modified:
  stable/12/sbin/fsck_msdosfs/boot.c
  stable/12/sbin/fsck_msdosfs/dir.c
  stable/12/sbin/fsck_msdosfs/dosfs.h
  stable/12/sbin/fsck_msdosfs/fat.c
  stable/12/sbin/fsck_msdosfs/main.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sbin/fsck_msdosfs/boot.c
==
--- stable/12/sbin/fsck_msdosfs/boot.c  Sat Nov 30 05:01:12 2019
(r355220)
+++ stable/12/sbin/fsck_msdosfs/boot.c  Sat Nov 30 05:43:24 2019
(r355221)
@@ -33,6 +33,9 @@ static const char rcsid[] =
   "$FreeBSD$";
 #endif /* not lint */
 
+#include 
+
+#include 
 #include 
 #include 
 #include 
@@ -46,10 +49,8 @@ readboot(int dosfs, struct bootblock *boot)
 {
u_char block[DOSBOOTBLOCKSIZE];
u_char fsinfo[2 * DOSBOOTBLOCKSIZE];
-   u_char backup[DOSBOOTBLOCKSIZE];
int ret = FSOK;
-   int i;
-   
+
if ((size_t)read(dosfs, block, sizeof block) != sizeof block) {
perr("could not read boot block");
return FSFATAL;
@@ -64,61 +65,133 @@ readboot(int dosfs, struct bootblock *boot)
memset(boot, 0, sizeof *boot);
boot->ValidFat = -1;
 
-   /* decode bios parameter block */
+   /* Decode BIOS Parameter Block */
+
+   /* Bytes per sector: can only be  512, 1024, 2048 and 4096. */
boot->bpbBytesPerSec = block[11] + (block[12] << 8);
+   if (boot->bpbBytesPerSec < DOSBOOTBLOCKSIZE_REAL ||
+   boot->bpbBytesPerSec > DOSBOOTBLOCKSIZE ||
+   !powerof2(boot->bpbBytesPerSec)) {
+   pfatal("Invalid sector size: %u", boot->bpbBytesPerSec);
+   return FSFATAL;
+   }
+
+   /* Sectors per cluster: can only be: 1, 2, 4, 8, 16, 32, 64, 128. */
boot->bpbSecPerClust = block[13];
+   if (boot->bpbSecPerClust == 0 || !powerof2(boot->bpbSecPerClust)) {
+   pfatal("Invalid cluster size: %u", boot->bpbSecPerClust);
+   return FSFATAL;
+   }
+
+   /* Reserved sectors: must be non-zero */
boot->bpbResSectors = block[14] + (block[15] << 8);
+   if (boot->bpbResSectors < 1) {
+   pfatal("Invalid reserved sectors: %u",
+   boot->bpbResSectors);
+   return FSFATAL;
+   }
+
+   /* Number of FATs */
boot->bpbFATs = block[16];
+   if (boot->bpbFATs == 0) {
+   pfatal("Invalid number of FATs: %u", boot->bpbFATs);
+   return FSFATAL;
+   }
+
+   /* Root directory entries for FAT12 and FAT16 */
boot->bpbRootDirEnts = block[17] + (block[18] << 8);
+   if (!boot->bpbRootDirEnts) {
+   /* bpbRootDirEnts = 0 suggests that we are FAT32 */
+   boot->flags |= FAT32;
+   }
+
+   /* Total sectors (16 bits) */
boot->bpbSectors = block[19] + (block[20] << 8);
+   if (boot->bpbSectors != 0 && (boot->flags & FAT32)) {
+   pfatal("Invalid 16-bit total sector count on FAT32: %u",
+   boot->bpbSectors);
+   return FSFATAL;
+   }
+
+   /* Media type: ignored */
boot->bpbMedia = block[21];
+
+   /* FAT12/FAT16: 16-bit count of sectors per FAT */
boot->bpbFATsmall = block[22] + (block[23] << 8);
+   if (boot->bpbFATsmall != 0 && (boot->flags & FAT32)) {
+   pfatal("Invalid 16-bit FAT sector count on FAT32: %u",
+   boot->bpbFATsmall);
+   return FSFATAL;
+   }
+
+   /* Legacy CHS geometry numbers: ignored */
boot->SecPerTrack = block[24] + (block[25] << 8);
boot->bpbHeads = block[26] + (block[27] << 8);
+
+   /* Hidden sectors: ignored */
boot->bpbHiddenSec

svn commit: r355220 - stable/11/etc/ntp

2019-11-29 Thread Xin LI
Author: delphij
Date: Sat Nov 30 05:01:12 2019
New Revision: 355220
URL: https://svnweb.freebsd.org/changeset/base/355220

Log:
  MFC r355128: Update leap-seconds to leap-seconds.3676924800.
  
  Obtained from:ftp://ftp.nist.gov/pub/time/leap-seconds.3676924800

Modified:
  stable/11/etc/ntp/leap-seconds
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/etc/ntp/leap-seconds
==
--- stable/11/etc/ntp/leap-seconds  Sat Nov 30 04:55:17 2019
(r355219)
+++ stable/11/etc/ntp/leap-seconds  Sat Nov 30 05:01:12 2019
(r355220)
@@ -62,7 +62,7 @@
 #  Terry Quinn, "The BIPM and the Accurate Measurement
 #  of Time," Proc. of the IEEE, Vol. 79, pp. 894-905,
 #  July, 1991. 
-#  reprinted in: 
+#  reprinted in:
 # Christine Hackman and Donald B Sullivan (eds.)
 # Time and Frequency Measurement
 # American Association of Physics Teachers (1996)
@@ -204,10 +204,10 @@
 #  current -- the update time stamp, the data and the name of the file
 #  will not change.
 #
-#  Updated through IERS Bulletin C57
-#  File expires on:  28 December 2019
+#  Updated through IERS Bulletin C58
+#  File expires on:  28 June 2020
 #
-#@ 378648
+#@ 3802291200
 #
 2272060800 10  # 1 Jan 1972
 2287785600 11  # 1 Jul 1972
@@ -252,4 +252,4 @@
 #  the hash line is also ignored in the
 #  computation.
 #
-#h 83c68138 d3650221 07dbbbcd 11fcc859 ced1106a
+#h f28827d2 f263b6c3 ec0f19eb a3e0dbf0 97f3fa30
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r355219 - stable/12/usr.sbin/ntp/ntpd

2019-11-29 Thread Xin LI
Author: delphij
Date: Sat Nov 30 04:55:17 2019
New Revision: 355219
URL: https://svnweb.freebsd.org/changeset/base/355219

Log:
  MFC r355128: Update leap-seconds to leap-seconds.3676924800.
  
  Obtained from:ftp://ftp.nist.gov/pub/time/leap-seconds.3676924800

Modified:
  stable/12/usr.sbin/ntp/ntpd/leap-seconds
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/usr.sbin/ntp/ntpd/leap-seconds
==
--- stable/12/usr.sbin/ntp/ntpd/leap-secondsFri Nov 29 23:04:45 2019
(r355218)
+++ stable/12/usr.sbin/ntp/ntpd/leap-secondsSat Nov 30 04:55:17 2019
(r355219)
@@ -62,7 +62,7 @@
 #  Terry Quinn, "The BIPM and the Accurate Measurement
 #  of Time," Proc. of the IEEE, Vol. 79, pp. 894-905,
 #  July, 1991. 
-#  reprinted in: 
+#  reprinted in:
 # Christine Hackman and Donald B Sullivan (eds.)
 # Time and Frequency Measurement
 # American Association of Physics Teachers (1996)
@@ -204,10 +204,10 @@
 #  current -- the update time stamp, the data and the name of the file
 #  will not change.
 #
-#  Updated through IERS Bulletin C57
-#  File expires on:  28 December 2019
+#  Updated through IERS Bulletin C58
+#  File expires on:  28 June 2020
 #
-#@ 378648
+#@ 3802291200
 #
 2272060800 10  # 1 Jan 1972
 2287785600 11  # 1 Jul 1972
@@ -252,4 +252,4 @@
 #  the hash line is also ignored in the
 #  computation.
 #
-#h 83c68138 d3650221 07dbbbcd 11fcc859 ced1106a
+#h f28827d2 f263b6c3 ec0f19eb a3e0dbf0 97f3fa30
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r355128 - head/usr.sbin/ntp/ntpd

2019-11-26 Thread Xin LI
Author: delphij
Date: Wed Nov 27 07:51:29 2019
New Revision: 355128
URL: https://svnweb.freebsd.org/changeset/base/355128

Log:
  Update leap-seconds to leap-seconds.3676924800.
  
  Obtained from:ftp://ftp.nist.gov/pub/time/leap-seconds.3676924800
  MFC after:3 days

Modified:
  head/usr.sbin/ntp/ntpd/leap-seconds

Modified: head/usr.sbin/ntp/ntpd/leap-seconds
==
--- head/usr.sbin/ntp/ntpd/leap-seconds Wed Nov 27 03:18:35 2019
(r355127)
+++ head/usr.sbin/ntp/ntpd/leap-seconds Wed Nov 27 07:51:29 2019
(r355128)
@@ -62,7 +62,7 @@
 #  Terry Quinn, "The BIPM and the Accurate Measurement
 #  of Time," Proc. of the IEEE, Vol. 79, pp. 894-905,
 #  July, 1991. 
-#  reprinted in: 
+#  reprinted in:
 # Christine Hackman and Donald B Sullivan (eds.)
 # Time and Frequency Measurement
 # American Association of Physics Teachers (1996)
@@ -204,10 +204,10 @@
 #  current -- the update time stamp, the data and the name of the file
 #  will not change.
 #
-#  Updated through IERS Bulletin C57
-#  File expires on:  28 December 2019
+#  Updated through IERS Bulletin C58
+#  File expires on:  28 June 2020
 #
-#@ 378648
+#@ 3802291200
 #
 2272060800 10  # 1 Jan 1972
 2287785600 11  # 1 Jul 1972
@@ -252,4 +252,4 @@
 #  the hash line is also ignored in the
 #  computation.
 #
-#h 83c68138 d3650221 07dbbbcd 11fcc859 ced1106a
+#h f28827d2 f263b6c3 ec0f19eb a3e0dbf0 97f3fa30
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r355085 - in head: contrib/expat contrib/expat/doc contrib/expat/examples contrib/expat/lib contrib/expat/tests contrib/expat/tests/benchmark contrib/expat/xmlwf lib/libexpat

2019-11-24 Thread Xin LI
Author: delphij
Date: Mon Nov 25 07:48:16 2019
New Revision: 355085
URL: https://svnweb.freebsd.org/changeset/base/355085

Log:
  MFV r355071: libbsdxml (expat) 2.2.9.
  
  MFC after:2 weeks
  Relnotes: yes

Added:
  head/contrib/expat/fix-xmltest-log.sh
 - copied unchanged from r355071, vendor/expat/dist/fix-xmltest-log.sh
  head/contrib/expat/xmlwf/xmlwf_helpgen.py
 - copied unchanged from r355071, vendor/expat/dist/xmlwf/xmlwf_helpgen.py
  head/contrib/expat/xmlwf/xmlwf_helpgen.sh
 - copied unchanged from r355071, vendor/expat/dist/xmlwf/xmlwf_helpgen.sh
Modified:
  head/contrib/expat/Changes
  head/contrib/expat/FREEBSD-Xlist
  head/contrib/expat/Makefile.am
  head/contrib/expat/Makefile.in
  head/contrib/expat/README.md
  head/contrib/expat/configure.ac
  head/contrib/expat/doc/Makefile.am
  head/contrib/expat/doc/Makefile.in
  head/contrib/expat/doc/reference.html
  head/contrib/expat/examples/Makefile.in
  head/contrib/expat/examples/elements.c
  head/contrib/expat/examples/outline.c
  head/contrib/expat/expat_config.h.in
  head/contrib/expat/lib/Makefile.am
  head/contrib/expat/lib/Makefile.in
  head/contrib/expat/lib/asciitab.h
  head/contrib/expat/lib/expat.h
  head/contrib/expat/lib/expat_external.h
  head/contrib/expat/lib/iasciitab.h
  head/contrib/expat/lib/internal.h
  head/contrib/expat/lib/latin1tab.h
  head/contrib/expat/lib/nametab.h
  head/contrib/expat/lib/siphash.h
  head/contrib/expat/lib/utf8tab.h
  head/contrib/expat/lib/xmlparse.c
  head/contrib/expat/lib/xmlrole.c
  head/contrib/expat/lib/xmlrole.h
  head/contrib/expat/lib/xmltok.c
  head/contrib/expat/lib/xmltok.h
  head/contrib/expat/lib/xmltok_impl.c
  head/contrib/expat/lib/xmltok_impl.h
  head/contrib/expat/lib/xmltok_ns.c
  head/contrib/expat/test-driver-wrapper.sh
  head/contrib/expat/tests/Makefile.in
  head/contrib/expat/tests/benchmark/Makefile.in
  head/contrib/expat/tests/benchmark/benchmark.c
  head/contrib/expat/tests/chardata.c
  head/contrib/expat/tests/chardata.h
  head/contrib/expat/tests/memcheck.c
  head/contrib/expat/tests/memcheck.h
  head/contrib/expat/tests/minicheck.c
  head/contrib/expat/tests/minicheck.h
  head/contrib/expat/tests/runtests.c
  head/contrib/expat/tests/structdata.c
  head/contrib/expat/tests/structdata.h
  head/contrib/expat/tests/xmltest.sh
  head/contrib/expat/xmlwf/Makefile.am
  head/contrib/expat/xmlwf/Makefile.in
  head/contrib/expat/xmlwf/codepage.c
  head/contrib/expat/xmlwf/ct.c
  head/contrib/expat/xmlwf/filemap.h
  head/contrib/expat/xmlwf/readfilemap.c
  head/contrib/expat/xmlwf/unixfilemap.c
  head/contrib/expat/xmlwf/win32filemap.c
  head/contrib/expat/xmlwf/xmlfile.c
  head/contrib/expat/xmlwf/xmlfile.h
  head/contrib/expat/xmlwf/xmlmime.c
  head/contrib/expat/xmlwf/xmltchar.h
  head/contrib/expat/xmlwf/xmlwf.c
  head/lib/libexpat/expat_config.h
  head/lib/libexpat/libbsdxml.3
Directory Properties:
  head/contrib/expat/   (props changed)

Modified: head/contrib/expat/Changes
==
--- head/contrib/expat/Changes  Mon Nov 25 07:38:31 2019(r355084)
+++ head/contrib/expat/Changes  Mon Nov 25 07:48:16 2019(r355085)
@@ -2,6 +2,162 @@ NOTE: We are looking for help with a few things:
   https://github.com/libexpat/libexpat/labels/help%20wanted
   If you can help, please get in touch.  Thanks!
 
+Release 2.2.9 Wed Septemper 25 2019
+Other changes:
+  examples: Drop executable bits from elements.c
+#349  Windows: Change the name of the Windows DLLs from expat*.dll
+to libexpat*.dll once more (regression from 2.2.8, first
+fixed in 1.95.3, issue #61 on SourceForge today,
+was issue #432456 back then); needs a fix due
+case-insensitive file systems on Windows and the fact that
+Perl's XML::Parser::Expat compiles into Expat.dll.
+#347  Windows: Only define _CRT_RAND_S if not defined
+  Version info bumped from 7:10:6 to 7:11:6
+
+Special thanks to:
+Ben Wagner
+
+Release 2.2.8 Fri Septemper 13 2019
+Security fixes:
+   #317 #318  CVE-2019-15903 -- Fix heap overflow triggered by
+XML_GetCurrentLineNumber (or XML_GetCurrentColumnNumber),
+and deny internal entities closing the doctype;
+fixed in commit c20b758c332d9a13afbbb276d30db1d183a85d43
+
+Bug fixes:
+#240  Fix cases where XML_StopParser did not have any effect
+when called from inside of an end element handler
+#341  xmlwf: Fix exit code for operation without "-d DIRECTORY";
+previously, only "-d DIRECTORY" would give you a proper
+exit code:
+  # xmlwf -d . <<<'' 2>/dev/null ; echo $?
+  2
+  # xmlwf <<<'' 2>/dev/nu

svn commit: r355071 - in vendor/expat/dist: . doc examples lib tests tests/benchmark xmlwf

2019-11-24 Thread Xin LI
Author: delphij
Date: Sun Nov 24 23:46:29 2019
New Revision: 355071
URL: https://svnweb.freebsd.org/changeset/base/355071

Log:
  Vendor import of expat 2.2.9

Added:
  vendor/expat/dist/fix-xmltest-log.sh   (contents, props changed)
  vendor/expat/dist/xmlwf/xmlwf_helpgen.py   (contents, props changed)
  vendor/expat/dist/xmlwf/xmlwf_helpgen.sh   (contents, props changed)
Modified:
  vendor/expat/dist/Changes
  vendor/expat/dist/FREEBSD-Xlist
  vendor/expat/dist/Makefile.am
  vendor/expat/dist/Makefile.in
  vendor/expat/dist/README.md
  vendor/expat/dist/configure.ac
  vendor/expat/dist/doc/Makefile.am
  vendor/expat/dist/doc/Makefile.in
  vendor/expat/dist/doc/reference.html
  vendor/expat/dist/examples/Makefile.in
  vendor/expat/dist/examples/elements.c
  vendor/expat/dist/examples/outline.c
  vendor/expat/dist/expat_config.h.in
  vendor/expat/dist/lib/Makefile.am
  vendor/expat/dist/lib/Makefile.in
  vendor/expat/dist/lib/asciitab.h
  vendor/expat/dist/lib/expat.h
  vendor/expat/dist/lib/expat_external.h
  vendor/expat/dist/lib/iasciitab.h
  vendor/expat/dist/lib/internal.h
  vendor/expat/dist/lib/latin1tab.h
  vendor/expat/dist/lib/nametab.h
  vendor/expat/dist/lib/siphash.h
  vendor/expat/dist/lib/utf8tab.h
  vendor/expat/dist/lib/xmlparse.c
  vendor/expat/dist/lib/xmlrole.c
  vendor/expat/dist/lib/xmlrole.h
  vendor/expat/dist/lib/xmltok.c
  vendor/expat/dist/lib/xmltok.h
  vendor/expat/dist/lib/xmltok_impl.c
  vendor/expat/dist/lib/xmltok_impl.h
  vendor/expat/dist/lib/xmltok_ns.c
  vendor/expat/dist/test-driver-wrapper.sh
  vendor/expat/dist/tests/Makefile.in
  vendor/expat/dist/tests/benchmark/Makefile.in
  vendor/expat/dist/tests/benchmark/benchmark.c
  vendor/expat/dist/tests/chardata.c
  vendor/expat/dist/tests/chardata.h
  vendor/expat/dist/tests/memcheck.c
  vendor/expat/dist/tests/memcheck.h
  vendor/expat/dist/tests/minicheck.c
  vendor/expat/dist/tests/minicheck.h
  vendor/expat/dist/tests/runtests.c
  vendor/expat/dist/tests/structdata.c
  vendor/expat/dist/tests/structdata.h
  vendor/expat/dist/tests/xmltest.sh
  vendor/expat/dist/xmlwf/Makefile.am
  vendor/expat/dist/xmlwf/Makefile.in
  vendor/expat/dist/xmlwf/codepage.c
  vendor/expat/dist/xmlwf/ct.c
  vendor/expat/dist/xmlwf/filemap.h
  vendor/expat/dist/xmlwf/readfilemap.c
  vendor/expat/dist/xmlwf/unixfilemap.c
  vendor/expat/dist/xmlwf/win32filemap.c
  vendor/expat/dist/xmlwf/xmlfile.c
  vendor/expat/dist/xmlwf/xmlfile.h
  vendor/expat/dist/xmlwf/xmlmime.c
  vendor/expat/dist/xmlwf/xmltchar.h
  vendor/expat/dist/xmlwf/xmlwf.c

Modified: vendor/expat/dist/Changes
==
--- vendor/expat/dist/Changes   Sun Nov 24 23:21:47 2019(r355070)
+++ vendor/expat/dist/Changes   Sun Nov 24 23:46:29 2019(r355071)
@@ -2,6 +2,162 @@ NOTE: We are looking for help with a few things:
   https://github.com/libexpat/libexpat/labels/help%20wanted
   If you can help, please get in touch.  Thanks!
 
+Release 2.2.9 Wed Septemper 25 2019
+Other changes:
+  examples: Drop executable bits from elements.c
+#349  Windows: Change the name of the Windows DLLs from expat*.dll
+to libexpat*.dll once more (regression from 2.2.8, first
+fixed in 1.95.3, issue #61 on SourceForge today,
+was issue #432456 back then); needs a fix due
+case-insensitive file systems on Windows and the fact that
+Perl's XML::Parser::Expat compiles into Expat.dll.
+#347  Windows: Only define _CRT_RAND_S if not defined
+  Version info bumped from 7:10:6 to 7:11:6
+
+Special thanks to:
+Ben Wagner
+
+Release 2.2.8 Fri Septemper 13 2019
+Security fixes:
+   #317 #318  CVE-2019-15903 -- Fix heap overflow triggered by
+XML_GetCurrentLineNumber (or XML_GetCurrentColumnNumber),
+and deny internal entities closing the doctype;
+fixed in commit c20b758c332d9a13afbbb276d30db1d183a85d43
+
+Bug fixes:
+#240  Fix cases where XML_StopParser did not have any effect
+when called from inside of an end element handler
+#341  xmlwf: Fix exit code for operation without "-d DIRECTORY";
+previously, only "-d DIRECTORY" would give you a proper
+exit code:
+  # xmlwf -d . <<<'' 2>/dev/null ; echo $?
+  2
+  # xmlwf <<<'' 2>/dev/null ; echo $?
+  0
+Now both cases return exit code 2.
+
+Other changes:
+   #299 #302  Windows: Replace LoadLibrary hack to access
+unofficial API function SystemFunction036 (RtlGenRandom)
+by using official API function rand_s (needs WinXP+)
+#325  Windows: Drop support for Visual Studio <=7

svn commit: r354939 - in stable/11: contrib/file contrib/file/doc contrib/file/magic contrib/file/magic/Magdir contrib/file/src contrib/file/tests lib/libmagic

2019-11-20 Thread Xin LI
Author: delphij
Date: Thu Nov 21 07:39:33 2019
New Revision: 354939
URL: https://svnweb.freebsd.org/changeset/base/354939

Log:
  MFC r333923, r354595, r354802:
  
  MFV r354582: file 5.37
  
  MFV r354798:
  
  Apply vendor fixes:
  
  06de62c Detect multiplication overflow when computing sector position
  46a8443 Limit the number of elements in a vector (found by oss-fuzz)
  
  Security:   CVE-2019-18218

Added:
  stable/11/contrib/file/magic/Magdir/biosig
 - copied unchanged from r354595, head/contrib/file/magic/Magdir/biosig
  stable/11/contrib/file/magic/Magdir/clojure
 - copied unchanged from r354595, head/contrib/file/magic/Magdir/clojure
  stable/11/contrib/file/magic/Magdir/edid
 - copied unchanged from r354595, head/contrib/file/magic/Magdir/edid
  stable/11/contrib/file/magic/Magdir/espressif
 - copied unchanged from r354595, head/contrib/file/magic/Magdir/espressif
  stable/11/contrib/file/magic/Magdir/glibc
 - copied unchanged from r354595, head/contrib/file/magic/Magdir/glibc
  stable/11/contrib/file/magic/Magdir/hardware
 - copied unchanged from r354595, head/contrib/file/magic/Magdir/hardware
  stable/11/contrib/file/magic/Magdir/kicad
 - copied unchanged from r354595, head/contrib/file/magic/Magdir/kicad
  stable/11/contrib/file/magic/Magdir/numpy
 - copied unchanged from r354595, head/contrib/file/magic/Magdir/numpy
  stable/11/contrib/file/magic/Magdir/rpmsg
 - copied unchanged from r354595, head/contrib/file/magic/Magdir/rpmsg
  stable/11/contrib/file/src/is_json.c
 - copied unchanged from r354595, head/contrib/file/src/is_json.c
  stable/11/contrib/file/tests/CVE-2014-1943.result
 - copied unchanged from r354595, 
head/contrib/file/tests/CVE-2014-1943.result
  stable/11/contrib/file/tests/CVE-2014-1943.testfile
 - copied unchanged from r354595, 
head/contrib/file/tests/CVE-2014-1943.testfile
  stable/11/contrib/file/tests/fit-map-data.result
 - copied unchanged from r354595, 
head/contrib/file/tests/fit-map-data.result
  stable/11/contrib/file/tests/fit-map-data.testfile
 - copied unchanged from r354595, 
head/contrib/file/tests/fit-map-data.testfile
  stable/11/contrib/file/tests/issue359xlsx.result
 - copied unchanged from r354595, 
head/contrib/file/tests/issue359xlsx.result
  stable/11/contrib/file/tests/issue359xlsx.testfile
 - copied unchanged from r354595, 
head/contrib/file/tests/issue359xlsx.testfile
  stable/11/contrib/file/tests/json1.result
 - copied unchanged from r354595, head/contrib/file/tests/json1.result
  stable/11/contrib/file/tests/json1.testfile
 - copied unchanged from r354595, head/contrib/file/tests/json1.testfile
  stable/11/contrib/file/tests/json2.result
 - copied unchanged from r354595, head/contrib/file/tests/json2.result
  stable/11/contrib/file/tests/json2.testfile
 - copied unchanged from r354595, head/contrib/file/tests/json2.testfile
  stable/11/contrib/file/tests/json3.result
 - copied unchanged from r354595, head/contrib/file/tests/json3.result
  stable/11/contrib/file/tests/json3.testfile
 - copied unchanged from r354595, head/contrib/file/tests/json3.testfile
  stable/11/contrib/file/tests/regex-eol.magic
 - copied unchanged from r354595, head/contrib/file/tests/regex-eol.magic
  stable/11/contrib/file/tests/regex-eol.result
 - copied unchanged from r354595, head/contrib/file/tests/regex-eol.result
  stable/11/contrib/file/tests/regex-eol.testfile
 - copied unchanged from r354595, head/contrib/file/tests/regex-eol.testfile
  stable/11/contrib/file/tests/zstd-3-skippable-frames.result
 - copied unchanged from r354595, 
head/contrib/file/tests/zstd-3-skippable-frames.result
  stable/11/contrib/file/tests/zstd-dictionary-0.result
 - copied unchanged from r354595, 
head/contrib/file/tests/zstd-dictionary-0.result
  stable/11/contrib/file/tests/zstd-dictionary-1.result
 - copied unchanged from r354595, 
head/contrib/file/tests/zstd-dictionary-1.result
  stable/11/contrib/file/tests/zstd-dictionary-2.result
 - copied unchanged from r354595, 
head/contrib/file/tests/zstd-dictionary-2.result
  stable/11/contrib/file/tests/zstd-skippable-frame-0.result
 - copied unchanged from r354595, 
head/contrib/file/tests/zstd-skippable-frame-0.result
  stable/11/contrib/file/tests/zstd-skippable-frame-4.result
 - copied unchanged from r354595, 
head/contrib/file/tests/zstd-skippable-frame-4.result
  stable/11/contrib/file/tests/zstd-skippable-frame-8.result
 - copied unchanged from r354595, 
head/contrib/file/tests/zstd-skippable-frame-8.result
  stable/11/contrib/file/tests/zstd-skippable-frame-C.result
 - copied unchanged from r354595, 
head/contrib/file/tests/zstd-skippable-frame-C.result
  stable/11/contrib/file/tests/zstd-v0.2-FF.result
 - copied unchanged from r354595, 
head/contrib/file/tests/zstd-v0.2-FF.result
  stable/11/contrib/file/tests/zstd-v0.2-FF.testfile
 - copied unchanged from r354595, 
head/contrib/file/te

svn commit: r354938 - in stable/12: contrib/file contrib/file/doc contrib/file/magic contrib/file/magic/Magdir contrib/file/src contrib/file/tests lib/libmagic

2019-11-20 Thread Xin LI
Author: delphij
Date: Thu Nov 21 07:29:25 2019
New Revision: 354938
URL: https://svnweb.freebsd.org/changeset/base/354938

Log:
  MFC r354595, r354802:
  
  MFV r354582: file 5.37
  
  MFV r354798:
  
  Apply vendor fixes:
  
  06de62c Detect multiplication overflow when computing sector position
  46a8443 Limit the number of elements in a vector (found by oss-fuzz)
  
  Security:   CVE-2019-18218

Added:
  stable/12/contrib/file/magic/Magdir/biosig
 - copied unchanged from r354595, head/contrib/file/magic/Magdir/biosig
  stable/12/contrib/file/magic/Magdir/clojure
 - copied unchanged from r354595, head/contrib/file/magic/Magdir/clojure
  stable/12/contrib/file/magic/Magdir/edid
 - copied unchanged from r354595, head/contrib/file/magic/Magdir/edid
  stable/12/contrib/file/magic/Magdir/espressif
 - copied unchanged from r354595, head/contrib/file/magic/Magdir/espressif
  stable/12/contrib/file/magic/Magdir/glibc
 - copied unchanged from r354595, head/contrib/file/magic/Magdir/glibc
  stable/12/contrib/file/magic/Magdir/hardware
 - copied unchanged from r354595, head/contrib/file/magic/Magdir/hardware
  stable/12/contrib/file/magic/Magdir/kicad
 - copied unchanged from r354595, head/contrib/file/magic/Magdir/kicad
  stable/12/contrib/file/magic/Magdir/numpy
 - copied unchanged from r354595, head/contrib/file/magic/Magdir/numpy
  stable/12/contrib/file/magic/Magdir/rpmsg
 - copied unchanged from r354595, head/contrib/file/magic/Magdir/rpmsg
  stable/12/contrib/file/src/is_json.c
 - copied unchanged from r354595, head/contrib/file/src/is_json.c
  stable/12/contrib/file/tests/CVE-2014-1943.result
 - copied unchanged from r354595, 
head/contrib/file/tests/CVE-2014-1943.result
  stable/12/contrib/file/tests/CVE-2014-1943.testfile
 - copied unchanged from r354595, 
head/contrib/file/tests/CVE-2014-1943.testfile
  stable/12/contrib/file/tests/fit-map-data.result
 - copied unchanged from r354595, 
head/contrib/file/tests/fit-map-data.result
  stable/12/contrib/file/tests/fit-map-data.testfile
 - copied unchanged from r354595, 
head/contrib/file/tests/fit-map-data.testfile
  stable/12/contrib/file/tests/issue359xlsx.result
 - copied unchanged from r354595, 
head/contrib/file/tests/issue359xlsx.result
  stable/12/contrib/file/tests/issue359xlsx.testfile
 - copied unchanged from r354595, 
head/contrib/file/tests/issue359xlsx.testfile
  stable/12/contrib/file/tests/json1.result
 - copied unchanged from r354595, head/contrib/file/tests/json1.result
  stable/12/contrib/file/tests/json1.testfile
 - copied unchanged from r354595, head/contrib/file/tests/json1.testfile
  stable/12/contrib/file/tests/json2.result
 - copied unchanged from r354595, head/contrib/file/tests/json2.result
  stable/12/contrib/file/tests/json2.testfile
 - copied unchanged from r354595, head/contrib/file/tests/json2.testfile
  stable/12/contrib/file/tests/json3.result
 - copied unchanged from r354595, head/contrib/file/tests/json3.result
  stable/12/contrib/file/tests/json3.testfile
 - copied unchanged from r354595, head/contrib/file/tests/json3.testfile
  stable/12/contrib/file/tests/regex-eol.magic
 - copied unchanged from r354595, head/contrib/file/tests/regex-eol.magic
  stable/12/contrib/file/tests/regex-eol.result
 - copied unchanged from r354595, head/contrib/file/tests/regex-eol.result
  stable/12/contrib/file/tests/regex-eol.testfile
 - copied unchanged from r354595, head/contrib/file/tests/regex-eol.testfile
  stable/12/contrib/file/tests/zstd-3-skippable-frames.result
 - copied unchanged from r354595, 
head/contrib/file/tests/zstd-3-skippable-frames.result
  stable/12/contrib/file/tests/zstd-dictionary-0.result
 - copied unchanged from r354595, 
head/contrib/file/tests/zstd-dictionary-0.result
  stable/12/contrib/file/tests/zstd-dictionary-1.result
 - copied unchanged from r354595, 
head/contrib/file/tests/zstd-dictionary-1.result
  stable/12/contrib/file/tests/zstd-dictionary-2.result
 - copied unchanged from r354595, 
head/contrib/file/tests/zstd-dictionary-2.result
  stable/12/contrib/file/tests/zstd-skippable-frame-0.result
 - copied unchanged from r354595, 
head/contrib/file/tests/zstd-skippable-frame-0.result
  stable/12/contrib/file/tests/zstd-skippable-frame-4.result
 - copied unchanged from r354595, 
head/contrib/file/tests/zstd-skippable-frame-4.result
  stable/12/contrib/file/tests/zstd-skippable-frame-8.result
 - copied unchanged from r354595, 
head/contrib/file/tests/zstd-skippable-frame-8.result
  stable/12/contrib/file/tests/zstd-skippable-frame-C.result
 - copied unchanged from r354595, 
head/contrib/file/tests/zstd-skippable-frame-C.result
  stable/12/contrib/file/tests/zstd-v0.2-FF.result
 - copied unchanged from r354595, 
head/contrib/file/tests/zstd-v0.2-FF.result
  stable/12/contrib/file/tests/zstd-v0.2-FF.testfile
 - copied unchanged from r354595, 
head/contrib/file/tests/zstd-

svn commit: r354802 - head/contrib/file/src

2019-11-17 Thread Xin LI
Author: delphij
Date: Mon Nov 18 04:22:04 2019
New Revision: 354802
URL: https://svnweb.freebsd.org/changeset/base/354802

Log:
  MFV r354798:
  
  Apply vendor fixes:
  
  06de62c Detect multiplication overflow when computing sector position
  46a8443 Limit the number of elements in a vector (found by oss-fuzz)
  
  Requested by: wen
  MFC after:3 days
  Security: CVE-2019-18218

Modified:
  head/contrib/file/src/cdf.c
  head/contrib/file/src/cdf.h
Directory Properties:
  head/contrib/file/   (props changed)

Modified: head/contrib/file/src/cdf.c
==
--- head/contrib/file/src/cdf.c Mon Nov 18 04:03:11 2019(r354801)
+++ head/contrib/file/src/cdf.c Mon Nov 18 04:22:04 2019(r354802)
@@ -35,7 +35,7 @@
 #include "file.h"
 
 #ifndef lint
-FILE_RCSID("@(#)$File: cdf.c,v 1.114 2019/02/20 02:35:27 christos Exp $")
+FILE_RCSID("@(#)$File: cdf.c,v 1.116 2019/08/26 14:31:39 christos Exp $")
 #endif
 
 #include 
@@ -53,6 +53,10 @@ FILE_RCSID("@(#)$File: cdf.c,v 1.114 2019/02/20 02:35:
 #define EFTYPE EINVAL
 #endif
 
+#ifndef SIZE_T_MAX
+#define SIZE_T_MAX CAST(size_t, ~0ULL)
+#endif
+
 #include "cdf.h"
 
 #ifdef CDF_DEBUG
@@ -405,7 +409,12 @@ cdf_read_sector(const cdf_info_t *info, void *buf, siz
 const cdf_header_t *h, cdf_secid_t id)
 {
size_t ss = CDF_SEC_SIZE(h);
-   size_t pos = CDF_SEC_POS(h, id);
+   size_t pos;
+
+   if (SIZE_T_MAX / ss < CAST(size_t, id))
+   return -1;
+
+   pos = CDF_SEC_POS(h, id);
assert(ss == len);
return cdf_read(info, CAST(off_t, pos), RCAST(char *, buf) + offs, len);
 }
@@ -415,7 +424,12 @@ cdf_read_short_sector(const cdf_stream_t *sst, void *b
 size_t len, const cdf_header_t *h, cdf_secid_t id)
 {
size_t ss = CDF_SHORT_SEC_SIZE(h);
-   size_t pos = CDF_SHORT_SEC_POS(h, id);
+   size_t pos;
+
+   if (SIZE_T_MAX / ss < CAST(size_t, id))
+   return -1;
+
+   pos = CDF_SHORT_SEC_POS(h, id);
assert(ss == len);
if (pos + len > CDF_SEC_SIZE(h) * sst->sst_len) {
DPRINTF(("Out of bounds read %" SIZE_T_FORMAT "u > %"
@@ -1013,8 +1027,9 @@ cdf_read_property_info(const cdf_stream_t *sst, const 
goto out;
}
nelements = CDF_GETUINT32(q, 1);
-   if (nelements == 0) {
-   DPRINTF(("CDF_VECTOR with nelements == 0\n"));
+   if (nelements > CDF_ELEMENT_LIMIT || nelements == 0) {
+   DPRINTF(("CDF_VECTOR with nelements == %"
+   SIZE_T_FORMAT "u\n", nelements));
goto out;
}
slen = 2;
@@ -1056,8 +1071,6 @@ cdf_read_property_info(const cdf_stream_t *sst, const 
goto out;
inp += nelem;
}
-   DPRINTF(("nelements = %" SIZE_T_FORMAT "u\n",
-   nelements));
for (j = 0; j < nelements && i < sh.sh_properties;
j++, i++)
{

Modified: head/contrib/file/src/cdf.h
==
--- head/contrib/file/src/cdf.h Mon Nov 18 04:03:11 2019(r354801)
+++ head/contrib/file/src/cdf.h Mon Nov 18 04:22:04 2019(r354802)
@@ -48,6 +48,7 @@
 typedef int32_t cdf_secid_t;
 
 #define CDF_LOOP_LIMIT 1
+#define CDF_ELEMENT_LIMIT  10
 
 #define CDF_SECID_NULL 0
 #define CDF_SECID_FREE -1
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r354798 - vendor/file/dist/src

2019-11-17 Thread Xin LI
Author: delphij
Date: Sun Nov 17 20:56:25 2019
New Revision: 354798
URL: https://svnweb.freebsd.org/changeset/base/354798

Log:
  Apply vendor fixes:
  
  06de62c Detect multiplication overflow when computing sector position
  
  46a8443 Limit the number of elements in a vector (found by oss-fuzz)

Modified:
  vendor/file/dist/src/cdf.c
  vendor/file/dist/src/cdf.h

Modified: vendor/file/dist/src/cdf.c
==
--- vendor/file/dist/src/cdf.c  Sun Nov 17 20:49:24 2019(r354797)
+++ vendor/file/dist/src/cdf.c  Sun Nov 17 20:56:25 2019(r354798)
@@ -35,7 +35,7 @@
 #include "file.h"
 
 #ifndef lint
-FILE_RCSID("@(#)$File: cdf.c,v 1.114 2019/02/20 02:35:27 christos Exp $")
+FILE_RCSID("@(#)$File: cdf.c,v 1.116 2019/08/26 14:31:39 christos Exp $")
 #endif
 
 #include 
@@ -53,6 +53,10 @@ FILE_RCSID("@(#)$File: cdf.c,v 1.114 2019/02/20 02:35:
 #define EFTYPE EINVAL
 #endif
 
+#ifndef SIZE_T_MAX
+#define SIZE_T_MAX CAST(size_t, ~0ULL)
+#endif
+
 #include "cdf.h"
 
 #ifdef CDF_DEBUG
@@ -405,7 +409,12 @@ cdf_read_sector(const cdf_info_t *info, void *buf, siz
 const cdf_header_t *h, cdf_secid_t id)
 {
size_t ss = CDF_SEC_SIZE(h);
-   size_t pos = CDF_SEC_POS(h, id);
+   size_t pos;
+
+   if (SIZE_T_MAX / ss < CAST(size_t, id))
+   return -1;
+
+   pos = CDF_SEC_POS(h, id);
assert(ss == len);
return cdf_read(info, CAST(off_t, pos), RCAST(char *, buf) + offs, len);
 }
@@ -415,7 +424,12 @@ cdf_read_short_sector(const cdf_stream_t *sst, void *b
 size_t len, const cdf_header_t *h, cdf_secid_t id)
 {
size_t ss = CDF_SHORT_SEC_SIZE(h);
-   size_t pos = CDF_SHORT_SEC_POS(h, id);
+   size_t pos;
+
+   if (SIZE_T_MAX / ss < CAST(size_t, id))
+   return -1;
+
+   pos = CDF_SHORT_SEC_POS(h, id);
assert(ss == len);
if (pos + len > CDF_SEC_SIZE(h) * sst->sst_len) {
DPRINTF(("Out of bounds read %" SIZE_T_FORMAT "u > %"
@@ -1013,8 +1027,9 @@ cdf_read_property_info(const cdf_stream_t *sst, const 
goto out;
}
nelements = CDF_GETUINT32(q, 1);
-   if (nelements == 0) {
-   DPRINTF(("CDF_VECTOR with nelements == 0\n"));
+   if (nelements > CDF_ELEMENT_LIMIT || nelements == 0) {
+   DPRINTF(("CDF_VECTOR with nelements == %"
+   SIZE_T_FORMAT "u\n", nelements));
goto out;
}
slen = 2;
@@ -1056,8 +1071,6 @@ cdf_read_property_info(const cdf_stream_t *sst, const 
goto out;
inp += nelem;
}
-   DPRINTF(("nelements = %" SIZE_T_FORMAT "u\n",
-   nelements));
for (j = 0; j < nelements && i < sh.sh_properties;
j++, i++)
{

Modified: vendor/file/dist/src/cdf.h
==
--- vendor/file/dist/src/cdf.h  Sun Nov 17 20:49:24 2019(r354797)
+++ vendor/file/dist/src/cdf.h  Sun Nov 17 20:56:25 2019(r354798)
@@ -48,6 +48,7 @@
 typedef int32_t cdf_secid_t;
 
 #define CDF_LOOP_LIMIT 1
+#define CDF_ELEMENT_LIMIT  10
 
 #define CDF_SECID_NULL 0
 #define CDF_SECID_FREE -1
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r354595 - in head: contrib/file contrib/file/doc contrib/file/magic contrib/file/magic/Magdir contrib/file/src contrib/file/tests lib/libmagic

2019-11-10 Thread Xin LI
Author: delphij
Date: Sun Nov 10 17:00:23 2019
New Revision: 354595
URL: https://svnweb.freebsd.org/changeset/base/354595

Log:
  MFV r354582: file 5.37.
  
  MFC after:3 days

Added:
  head/contrib/file/magic/Magdir/biosig
 - copied unchanged from r354582, vendor/file/dist/magic/Magdir/biosig
  head/contrib/file/magic/Magdir/clojure
 - copied unchanged from r354582, vendor/file/dist/magic/Magdir/clojure
  head/contrib/file/magic/Magdir/edid
 - copied unchanged from r354582, vendor/file/dist/magic/Magdir/edid
  head/contrib/file/magic/Magdir/espressif
 - copied unchanged from r354582, vendor/file/dist/magic/Magdir/espressif
  head/contrib/file/magic/Magdir/glibc
 - copied unchanged from r354582, vendor/file/dist/magic/Magdir/glibc
  head/contrib/file/magic/Magdir/hardware
 - copied unchanged from r354582, vendor/file/dist/magic/Magdir/hardware
  head/contrib/file/magic/Magdir/kicad
 - copied unchanged from r354582, vendor/file/dist/magic/Magdir/kicad
  head/contrib/file/magic/Magdir/numpy
 - copied unchanged from r354582, vendor/file/dist/magic/Magdir/numpy
  head/contrib/file/magic/Magdir/rpmsg
 - copied unchanged from r354582, vendor/file/dist/magic/Magdir/rpmsg
  head/contrib/file/src/is_json.c
 - copied unchanged from r354582, vendor/file/dist/src/is_json.c
  head/contrib/file/tests/CVE-2014-1943.result
 - copied unchanged from r354582, 
vendor/file/dist/tests/CVE-2014-1943.result
  head/contrib/file/tests/CVE-2014-1943.testfile
 - copied unchanged from r354582, 
vendor/file/dist/tests/CVE-2014-1943.testfile
  head/contrib/file/tests/fit-map-data.result
 - copied unchanged from r354582, vendor/file/dist/tests/fit-map-data.result
  head/contrib/file/tests/fit-map-data.testfile
 - copied unchanged from r354582, 
vendor/file/dist/tests/fit-map-data.testfile
  head/contrib/file/tests/issue359xlsx.result
 - copied unchanged from r354582, vendor/file/dist/tests/issue359xlsx.result
  head/contrib/file/tests/issue359xlsx.testfile
 - copied unchanged from r354582, 
vendor/file/dist/tests/issue359xlsx.testfile
  head/contrib/file/tests/json1.result
 - copied unchanged from r354582, vendor/file/dist/tests/json1.result
  head/contrib/file/tests/json1.testfile
 - copied unchanged from r354582, vendor/file/dist/tests/json1.testfile
  head/contrib/file/tests/json2.result
 - copied unchanged from r354582, vendor/file/dist/tests/json2.result
  head/contrib/file/tests/json2.testfile
 - copied unchanged from r354582, vendor/file/dist/tests/json2.testfile
  head/contrib/file/tests/json3.result
 - copied unchanged from r354582, vendor/file/dist/tests/json3.result
  head/contrib/file/tests/json3.testfile
 - copied unchanged from r354582, vendor/file/dist/tests/json3.testfile
  head/contrib/file/tests/regex-eol.magic
 - copied unchanged from r354582, vendor/file/dist/tests/regex-eol.magic
  head/contrib/file/tests/regex-eol.result
 - copied unchanged from r354582, vendor/file/dist/tests/regex-eol.result
  head/contrib/file/tests/regex-eol.testfile
 - copied unchanged from r354582, vendor/file/dist/tests/regex-eol.testfile
  head/contrib/file/tests/zstd-3-skippable-frames.result
 - copied unchanged from r354582, 
vendor/file/dist/tests/zstd-3-skippable-frames.result
  head/contrib/file/tests/zstd-dictionary-0.result
 - copied unchanged from r354582, 
vendor/file/dist/tests/zstd-dictionary-0.result
  head/contrib/file/tests/zstd-dictionary-1.result
 - copied unchanged from r354582, 
vendor/file/dist/tests/zstd-dictionary-1.result
  head/contrib/file/tests/zstd-dictionary-2.result
 - copied unchanged from r354582, 
vendor/file/dist/tests/zstd-dictionary-2.result
  head/contrib/file/tests/zstd-skippable-frame-0.result
 - copied unchanged from r354582, 
vendor/file/dist/tests/zstd-skippable-frame-0.result
  head/contrib/file/tests/zstd-skippable-frame-4.result
 - copied unchanged from r354582, 
vendor/file/dist/tests/zstd-skippable-frame-4.result
  head/contrib/file/tests/zstd-skippable-frame-8.result
 - copied unchanged from r354582, 
vendor/file/dist/tests/zstd-skippable-frame-8.result
  head/contrib/file/tests/zstd-skippable-frame-C.result
 - copied unchanged from r354582, 
vendor/file/dist/tests/zstd-skippable-frame-C.result
  head/contrib/file/tests/zstd-v0.2-FF.result
 - copied unchanged from r354582, vendor/file/dist/tests/zstd-v0.2-FF.result
  head/contrib/file/tests/zstd-v0.2-FF.testfile
 - copied unchanged from r354582, 
vendor/file/dist/tests/zstd-v0.2-FF.testfile
  head/contrib/file/tests/zstd-v0.3-FF.result
 - copied unchanged from r354582, vendor/file/dist/tests/zstd-v0.3-FF.result
  head/contrib/file/tests/zstd-v0.3-FF.testfile
 - copied unchanged from r354582, 
vendor/file/dist/tests/zstd-v0.3-FF.testfile
  head/contrib/file/tests/zstd-v0.4-FF.result
 - copied unchanged from r354582, vendor/file/dist/tests/zstd-v0.4-FF.result
  head/contrib/file/tests/zstd-v0.4

svn commit: r354583 - vendor/file/5.37

2019-11-09 Thread Xin LI
Author: delphij
Date: Sun Nov 10 03:45:16 2019
New Revision: 354583
URL: https://svnweb.freebsd.org/changeset/base/354583

Log:
  Tag file 5.37.

Added:
  vendor/file/5.37/
 - copied from r354582, vendor/file/dist/
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r354582 - in vendor/file/dist: . doc magic magic/Magdir src tests

2019-11-09 Thread Xin LI
Author: delphij
Date: Sun Nov 10 03:44:32 2019
New Revision: 354582
URL: https://svnweb.freebsd.org/changeset/base/354582

Log:
  Vendor import of file 5.37

Added:
  vendor/file/dist/magic/Magdir/biosig
  vendor/file/dist/magic/Magdir/clojure
  vendor/file/dist/magic/Magdir/edid
  vendor/file/dist/magic/Magdir/espressif
  vendor/file/dist/magic/Magdir/glibc
  vendor/file/dist/magic/Magdir/hardware
  vendor/file/dist/magic/Magdir/kicad
  vendor/file/dist/magic/Magdir/numpy
  vendor/file/dist/magic/Magdir/rpmsg
  vendor/file/dist/src/is_json.c   (contents, props changed)
  vendor/file/dist/tests/CVE-2014-1943.result
  vendor/file/dist/tests/CVE-2014-1943.testfile   (contents, props changed)
  vendor/file/dist/tests/fit-map-data.result
  vendor/file/dist/tests/fit-map-data.testfile   (contents, props changed)
  vendor/file/dist/tests/issue359xlsx.result
  vendor/file/dist/tests/issue359xlsx.testfile   (contents, props changed)
  vendor/file/dist/tests/json1.result
  vendor/file/dist/tests/json1.testfile
  vendor/file/dist/tests/json2.result
  vendor/file/dist/tests/json2.testfile
  vendor/file/dist/tests/json3.result
  vendor/file/dist/tests/json3.testfile
  vendor/file/dist/tests/regex-eol.magic
  vendor/file/dist/tests/regex-eol.result
  vendor/file/dist/tests/regex-eol.testfile
  vendor/file/dist/tests/zstd-3-skippable-frames.result
  vendor/file/dist/tests/zstd-dictionary-0.result
  vendor/file/dist/tests/zstd-dictionary-1.result
  vendor/file/dist/tests/zstd-dictionary-2.result
  vendor/file/dist/tests/zstd-skippable-frame-0.result
  vendor/file/dist/tests/zstd-skippable-frame-4.result
  vendor/file/dist/tests/zstd-skippable-frame-8.result
  vendor/file/dist/tests/zstd-skippable-frame-C.result
  vendor/file/dist/tests/zstd-v0.2-FF.result
  vendor/file/dist/tests/zstd-v0.2-FF.testfile   (contents, props changed)
  vendor/file/dist/tests/zstd-v0.3-FF.result
  vendor/file/dist/tests/zstd-v0.3-FF.testfile   (contents, props changed)
  vendor/file/dist/tests/zstd-v0.4-FF.result
  vendor/file/dist/tests/zstd-v0.4-FF.testfile   (contents, props changed)
  vendor/file/dist/tests/zstd-v0.5-FF.result
  vendor/file/dist/tests/zstd-v0.5-FF.testfile   (contents, props changed)
  vendor/file/dist/tests/zstd-v0.6-FF.result
  vendor/file/dist/tests/zstd-v0.6-FF.testfile   (contents, props changed)
  vendor/file/dist/tests/zstd-v0.7-00.result
  vendor/file/dist/tests/zstd-v0.7-21.result
  vendor/file/dist/tests/zstd-v0.7-21.testfile   (contents, props changed)
  vendor/file/dist/tests/zstd-v0.7-22.result
  vendor/file/dist/tests/zstd-v0.7-22.testfile   (contents, props changed)
  vendor/file/dist/tests/zstd-v0.8-00.result
  vendor/file/dist/tests/zstd-v0.8-01.result
  vendor/file/dist/tests/zstd-v0.8-01.testfile   (contents, props changed)
  vendor/file/dist/tests/zstd-v0.8-02.result
  vendor/file/dist/tests/zstd-v0.8-02.testfile   (contents, props changed)
  vendor/file/dist/tests/zstd-v0.8-03.result
  vendor/file/dist/tests/zstd-v0.8-03.testfile   (contents, props changed)
  vendor/file/dist/tests/zstd-v0.8-16.result
  vendor/file/dist/tests/zstd-v0.8-16.testfile   (contents, props changed)
  vendor/file/dist/tests/zstd-v0.8-20.result
  vendor/file/dist/tests/zstd-v0.8-20.testfile   (contents, props changed)
  vendor/file/dist/tests/zstd-v0.8-21.result
  vendor/file/dist/tests/zstd-v0.8-21.testfile   (contents, props changed)
  vendor/file/dist/tests/zstd-v0.8-22.result
  vendor/file/dist/tests/zstd-v0.8-22.testfile   (contents, props changed)
  vendor/file/dist/tests/zstd-v0.8-23.result
  vendor/file/dist/tests/zstd-v0.8-23.testfile   (contents, props changed)
  vendor/file/dist/tests/zstd-v0.8-F4.result
  vendor/file/dist/tests/zstd-v0.8-F4.testfile   (contents, props changed)
  vendor/file/dist/tests/zstd-v0.8-FF.result
  vendor/file/dist/tests/zstd-v0.8-FF.testfile   (contents, props changed)
Modified:
  vendor/file/dist/AUTHORS
  vendor/file/dist/COPYING
  vendor/file/dist/ChangeLog
  vendor/file/dist/NEWS
  vendor/file/dist/README
  vendor/file/dist/config.h.in
  vendor/file/dist/configure
  vendor/file/dist/configure.ac
  vendor/file/dist/doc/file.man
  vendor/file/dist/doc/libmagic.man
  vendor/file/dist/doc/magic.man
  vendor/file/dist/magic/Header
  vendor/file/dist/magic/Magdir/acorn
  vendor/file/dist/magic/Magdir/adventure
  vendor/file/dist/magic/Magdir/algol68
  vendor/file/dist/magic/Magdir/amigaos
  vendor/file/dist/magic/Magdir/android
  vendor/file/dist/magic/Magdir/animation
  vendor/file/dist/magic/Magdir/apple
  vendor/file/dist/magic/Magdir/archive
  vendor/file/dist/magic/Magdir/audio
  vendor/file/dist/magic/Magdir/basis
  vendor/file/dist/magic/Magdir/ber
  vendor/file/dist/magic/Magdir/bioinformatics
  vendor/file/dist/magic/Magdir/blcr
  vendor/file/dist/magic/Magdir/blender
  vendor/file/dist/magic/Magdir/c-lang
  vendor/file/dist/magic/Magdir/cad
  vendor/file/dist/magic/Magdir/cafebabe
  vendor/file/dist/magic/Magdir/coff
  vendor/file/dist/magic/Magdir/commands
  vendor/file/dist/magic/

Re: svn commit: r354283 - in head: stand/libsa/zfs sys/cddl/boot/zfs

2019-11-03 Thread Xin Li via svn-src-all


On 2019-11-03 13:32, Toomas Soome wrote:
> 
> 
>> On 3. Nov 2019, at 22:39, Kevin Bowling  wrote:
>>
>> I believe this is/was a common configuration, at least the few
>> spinning disk based systems I have left have a slog.
>>
> 
> On boot pool? um. well, I’ll kick out that return then.

I think it's fine to simply ignore the log in loader, because it's a
read-only consumer.

The full-featured kernel ZFS code would skip replaying the log when
importing read-only, in that case we might see some outdated data, but
it's still guaranteed to be consistent by ZFS.

Cheers,

> 
> rgds,
> toomas
> 
>> On Sun, Nov 3, 2019 at 10:55 AM Andriy Gapon  wrote:
>>>
>>> On 03/11/2019 15:25, Toomas Soome wrote:
 Author: tsoome
 Date: Sun Nov  3 13:25:47 2019
 New Revision: 354283
 URL: https://svnweb.freebsd.org/changeset/base/354283

 Log:
  loader: we do not support booting from pool with log device

  If pool has log device, stop there and tell about it.
>>>
>>> Why?
>>>
 Modified:
  head/stand/libsa/zfs/zfs.c
  head/stand/libsa/zfs/zfsimpl.c
  head/sys/cddl/boot/zfs/zfsimpl.h
>>>
>>>
>>>
>>> --
>>> Andriy Gapon
>>> ___
>>> svn-src-h...@freebsd.org mailing list
>>> https://lists.freebsd.org/mailman/listinfo/svn-src-head
>>> To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
> 



signature.asc
Description: OpenPGP digital signature


Re: svn commit: r354283 - in head: stand/libsa/zfs sys/cddl/boot/zfs

2019-11-03 Thread Xin Li via svn-src-all
(chosen a random message)

On 2019-11-03 15:30, Ravi Pokala wrote:
> Uh
> 
> I've had a log device in my boot-pool for months, and have booted without 
> issue:
> 
> [threepio:~] rpokala% zpool status zroot
>   pool: zroot
>  state: ONLINE
>   scan: scrub repaired 0 in 0 days 00:04:36 with 0 errors on Mon Oct 28 
> 03:10:59 2019
> config:
> 
> NAMESTATE READ WRITE CKSUM
> zroot   ONLINE   0 0 0
>   nvd1p4ONLINE   0 0 0
> logs
>   nvd0p1ONLINE   0 0 0
> 
> errors: No known data errors


This is not supported, and it's not trivial to support it, because in
order to support it, the bootloader would have to know how to replay
zilogs, which would add quite a lot of code to it.

It's unlikely that you actually hit a problem, however, because the
critical contents to boot the system is rarely written to, and as a
result it's quite likely that the readable, consistent state of your
/boot/ is good enough to boot the system.  That's said, it's still
because you were lucky, and the code was not designed to work that way...

Cheers,



signature.asc
Description: OpenPGP digital signature


Re: svn commit: r337669 - in head: cddl/contrib/opensolaris/cmd/zdb cddl/contrib/opensolaris/cmd/ztest cddl/usr.bin/ztest sys/cddl/contrib/opensolaris/common/zfs sys/cddl/contrib/opensolaris/uts/commo

2019-10-07 Thread Xin LI
+1.  org.zfsonlinux:large_dnode is the only missing feature right now from
the manual page (org.open-zfs:large_block was misspelled; we didn't enabled
org.illumos:edonr).


On Thu, Oct 18, 2018 at 12:12 PM Mark Felder  wrote:

> On Sat, Aug 11, 2018, at 19:45, Matt Macy wrote:
> > Author: mmacy
> > Date: Sun Aug 12 00:45:53 2018
> > New Revision: 337669
> > URL: https://svnweb.freebsd.org/changeset/base/337669
> >
> > Log:
> >   MFV/ZoL: Implement large_dnode pool feature
> >
>
> I just noticed this feature is missing from zpool-features.7 man page. Is
> there an entry we can borrow from ZoL or OpenZFS?
>
> --
>   Mark Felder
>   ports-secteam & portmgr member
>   f...@freebsd.org
>
>
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r352902 - releng/12.1/sbin/fsck_msdosfs

2019-09-30 Thread Xin LI
Author: delphij
Date: Mon Sep 30 14:32:41 2019
New Revision: 352902
URL: https://svnweb.freebsd.org/changeset/base/352902

Log:
  MFS r352872: MFC r351802:
  
  Correct overflow logic in fullpath().
  
  Obtained from:OpenBSD
  Approved by:  re (gjb)

Modified:
  releng/12.1/sbin/fsck_msdosfs/dir.c
Directory Properties:
  releng/12.1/   (props changed)

Modified: releng/12.1/sbin/fsck_msdosfs/dir.c
==
--- releng/12.1/sbin/fsck_msdosfs/dir.c Mon Sep 30 14:19:18 2019
(r352901)
+++ releng/12.1/sbin/fsck_msdosfs/dir.c Mon Sep 30 14:32:41 2019
(r352902)
@@ -168,20 +168,24 @@ fullpath(struct dosDirEntry *dir)
char *cp, *np;
int nl;
 
-   cp = namebuf + sizeof namebuf - 1;
-   *cp = '\0';
-   do {
+   cp = namebuf + sizeof namebuf;
+   *--cp = '\0';
+
+   for(;;) {
np = dir->lname[0] ? dir->lname : dir->name;
nl = strlen(np);
-   if ((cp -= nl) <= namebuf + 1)
+   if (cp <= namebuf + 1 + nl) {
+   *--cp = '?';
break;
+   }
+   cp -= nl;
memcpy(cp, np, nl);
+   dir = dir->parent;
+   if (!dir)
+   break;
*--cp = '/';
-   } while ((dir = dir->parent) != NULL);
-   if (dir)
-   *--cp = '?';
-   else
-   cp++;
+   }
+
return cp;
 }
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r352891 - stable/12/sys/dev/sound/pci/hda

2019-09-30 Thread Xin LI
Author: delphij
Date: Mon Sep 30 07:27:07 2019
New Revision: 352891
URL: https://svnweb.freebsd.org/changeset/base/352891

Log:
  MFC r351325:
  
  r351325: Fix sound on headset jack for ThinkPad T51.

Modified:
  stable/12/sys/dev/sound/pci/hda/hdaa_patches.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/sound/pci/hda/hdaa_patches.c
==
--- stable/12/sys/dev/sound/pci/hda/hdaa_patches.c  Mon Sep 30 06:38:34 
2019(r352890)
+++ stable/12/sys/dev/sound/pci/hda/hdaa_patches.c  Mon Sep 30 07:27:07 
2019(r352891)
@@ -429,6 +429,15 @@ hdac_pin_patch(struct hdaa_widget *w)
patch = "as=1 seq=15";
break;
}
+   } else if (id == HDA_CODEC_ALC298 && 
HDA_DEV_MATCH(LENOVO_ALL_SUBVENDOR, subid)) {
+   switch (nid) {
+   case 23:
+   config = 0x03a1103f;
+   break;
+   case 33:
+   config = 0x2121101f;
+   break;
+   }
} else if (id == HDA_CODEC_ALC298 && subid == DELL_XPS9560_SUBVENDOR) {
switch (nid) {
case 24:
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r352890 - stable/12/sys/kern

2019-09-29 Thread Xin LI
Author: delphij
Date: Mon Sep 30 06:38:34 2019
New Revision: 352890
URL: https://svnweb.freebsd.org/changeset/base/352890

Log:
  MFC r351417: r351417: INVARIANTS: treat LA_LOCKED as the same of LA_XLOCKED
  in mtx_assert.

Modified:
  stable/12/sys/kern/kern_mutex.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/kern/kern_mutex.c
==
--- stable/12/sys/kern/kern_mutex.c Mon Sep 30 06:09:32 2019
(r352889)
+++ stable/12/sys/kern/kern_mutex.c Mon Sep 30 06:38:34 2019
(r352890)
@@ -176,6 +176,21 @@ void
 assert_mtx(const struct lock_object *lock, int what)
 {
 
+   /*
+* Treat LA_LOCKED as if LA_XLOCKED was asserted.
+*
+* Some callers of lc_assert uses LA_LOCKED to indicate that either
+* a shared lock or write lock was held, while other callers uses
+* the more strict LA_XLOCKED (used as MA_OWNED).
+*
+* Mutex is the only lock class that can not be shared, as a result,
+* we can reasonably consider the caller really intends to assert
+* LA_XLOCKED when they are asserting LA_LOCKED on a mutex object.
+*/
+   if (what & LA_LOCKED) {
+   what &= ~LA_LOCKED;
+   what |= LA_XLOCKED;
+   }
mtx_assert((const struct mtx *)lock, what);
 }
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r352888 - stable/12/sys/contrib/zlib

2019-09-29 Thread Xin LI
Author: delphij
Date: Mon Sep 30 06:04:22 2019
New Revision: 352888
URL: https://svnweb.freebsd.org/changeset/base/352888

Log:
  MFC r351501: MFV r351500: Fix CLEAR_HASH macro to be usable as a single
  statement.

Modified:
  stable/12/sys/contrib/zlib/deflate.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/contrib/zlib/deflate.c
==
--- stable/12/sys/contrib/zlib/deflate.cMon Sep 30 05:43:57 2019
(r352887)
+++ stable/12/sys/contrib/zlib/deflate.cMon Sep 30 06:04:22 2019
(r352888)
@@ -190,8 +190,11 @@ local const config configuration_table[10] = {
  * prev[] will be initialized on the fly.
  */
 #define CLEAR_HASH(s) \
-s->head[s->hash_size-1] = NIL; \
-zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head));
+do { \
+s->head[s->hash_size-1] = NIL; \
+zmemzero((Bytef *)s->head, \
+ (unsigned)(s->hash_size-1)*sizeof(*s->head)); \
+} while (0)
 
 /* ===
  * Slide the hash table when sliding the window down (could be avoided with 32
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r352887 - stable/12/sbin/newfs_msdos

2019-09-29 Thread Xin LI
Author: delphij
Date: Mon Sep 30 05:43:57 2019
New Revision: 352887
URL: https://svnweb.freebsd.org/changeset/base/352887

Log:
  MFC r351382:
  
  When creating a new FAT32 filesystem, use "unknown" (0x) for
  FSI_Nxt_Free instead of providing a wrong value.
  
  With this change, fsck_msdosfs would no longer complain about invalid
  FSInfo information.

Modified:
  stable/12/sbin/newfs_msdos/mkfs_msdos.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sbin/newfs_msdos/mkfs_msdos.c
==
--- stable/12/sbin/newfs_msdos/mkfs_msdos.c Mon Sep 30 04:54:02 2019
(r352886)
+++ stable/12/sbin/newfs_msdos/mkfs_msdos.c Mon Sep 30 05:43:57 2019
(r352887)
@@ -717,7 +717,7 @@ mkfs_msdos(const char *fname, const char *dtype, const
mk4(img, 0x41615252);
mk4(img + MINBPS - 28, 0x61417272);
mk4(img + MINBPS - 24, 0x);
-   mk4(img + MINBPS - 20, bpb.bpbRootClust);
+   mk4(img + MINBPS - 20, 0x);
mk2(img + MINBPS - 2, DOSMAGIC);
} else if (lsn >= bpb.bpbResSectors && lsn < dir &&
   !((lsn - bpb.bpbResSectors) %
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r352873 - stable/11/sbin/fsck_msdosfs

2019-09-29 Thread Xin LI
Author: delphij
Date: Sun Sep 29 20:08:14 2019
New Revision: 352873
URL: https://svnweb.freebsd.org/changeset/base/352873

Log:
  MFC r351802:
  
  Correct overflow logic in fullpath().
  
  Obtained from:OpenBSD

Modified:
  stable/11/sbin/fsck_msdosfs/dir.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sbin/fsck_msdosfs/dir.c
==
--- stable/11/sbin/fsck_msdosfs/dir.c   Sun Sep 29 20:05:48 2019
(r352872)
+++ stable/11/sbin/fsck_msdosfs/dir.c   Sun Sep 29 20:08:14 2019
(r352873)
@@ -168,20 +168,24 @@ fullpath(struct dosDirEntry *dir)
char *cp, *np;
int nl;
 
-   cp = namebuf + sizeof namebuf - 1;
-   *cp = '\0';
-   do {
+   cp = namebuf + sizeof namebuf;
+   *--cp = '\0';
+
+   for(;;) {
np = dir->lname[0] ? dir->lname : dir->name;
nl = strlen(np);
-   if ((cp -= nl) <= namebuf + 1)
+   if (cp <= namebuf + 1 + nl) {
+   *--cp = '?';
break;
+   }
+   cp -= nl;
memcpy(cp, np, nl);
+   dir = dir->parent;
+   if (!dir)
+   break;
*--cp = '/';
-   } while ((dir = dir->parent) != NULL);
-   if (dir)
-   *--cp = '?';
-   else
-   cp++;
+   }
+
return cp;
 }
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r352872 - stable/12/sbin/fsck_msdosfs

2019-09-29 Thread Xin LI
Author: delphij
Date: Sun Sep 29 20:05:48 2019
New Revision: 352872
URL: https://svnweb.freebsd.org/changeset/base/352872

Log:
  MFC r351802:
  
  Correct overflow logic in fullpath().
  
  Obtained from:OpenBSD

Modified:
  stable/12/sbin/fsck_msdosfs/dir.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sbin/fsck_msdosfs/dir.c
==
--- stable/12/sbin/fsck_msdosfs/dir.c   Sun Sep 29 18:33:29 2019
(r352871)
+++ stable/12/sbin/fsck_msdosfs/dir.c   Sun Sep 29 20:05:48 2019
(r352872)
@@ -168,20 +168,24 @@ fullpath(struct dosDirEntry *dir)
char *cp, *np;
int nl;
 
-   cp = namebuf + sizeof namebuf - 1;
-   *cp = '\0';
-   do {
+   cp = namebuf + sizeof namebuf;
+   *--cp = '\0';
+
+   for(;;) {
np = dir->lname[0] ? dir->lname : dir->name;
nl = strlen(np);
-   if ((cp -= nl) <= namebuf + 1)
+   if (cp <= namebuf + 1 + nl) {
+   *--cp = '?';
break;
+   }
+   cp -= nl;
memcpy(cp, np, nl);
+   dir = dir->parent;
+   if (!dir)
+   break;
*--cp = '/';
-   } while ((dir = dir->parent) != NULL);
-   if (dir)
-   *--cp = '?';
-   else
-   cp++;
+   }
+
return cp;
 }
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r352364 - head/sbin/fsck_msdosfs

2019-09-15 Thread Xin LI
Author: delphij
Date: Sun Sep 15 19:41:54 2019
New Revision: 352364
URL: https://svnweb.freebsd.org/changeset/base/352364

Log:
  Avoid mixing cluster numbers and sector numbers. Makes code more readable.
  
  Obtained from:NetBSD
  MFC after:2 weeks

Modified:
  head/sbin/fsck_msdosfs/boot.c
  head/sbin/fsck_msdosfs/dir.c
  head/sbin/fsck_msdosfs/dosfs.h

Modified: head/sbin/fsck_msdosfs/boot.c
==
--- head/sbin/fsck_msdosfs/boot.c   Sun Sep 15 19:38:15 2019
(r352363)
+++ head/sbin/fsck_msdosfs/boot.c   Sun Sep 15 19:41:54 2019
(r352364)
@@ -259,12 +259,18 @@ readboot(int dosfs, struct bootblock *boot)
return FSFATAL;
}
 
-   boot->ClusterOffset = (boot->bpbRootDirEnts * 32 +
+   boot->FirstCluster = (boot->bpbRootDirEnts * 32 +
boot->bpbBytesPerSec - 1) / boot->bpbBytesPerSec +
-   boot->bpbResSectors + boot->bpbFATs * boot->FATsecs -
-   CLUST_FIRST * boot->bpbSecPerClust;
-   boot->NumClusters = (boot->NumSectors - boot->ClusterOffset) /
-   boot->bpbSecPerClust;
+   boot->bpbResSectors + boot->bpbFATs * boot->FATsecs;
+
+   if (boot->FirstCluster + boot->bpbSecPerClust > boot->NumSectors) {
+   pfatal("Cluster offset too large (%u clusters)\n",
+   boot->FirstCluster);
+   return FSFATAL;
+   }
+
+   boot->NumClusters = (boot->NumSectors - boot->FirstCluster) / 
boot->bpbSecPerClust +
+   CLUST_FIRST;
 
if (boot->flags & FAT32)
boot->ClustMask = CLUST32_MASK;

Modified: head/sbin/fsck_msdosfs/dir.c
==
--- head/sbin/fsck_msdosfs/dir.cSun Sep 15 19:38:15 2019
(r352363)
+++ head/sbin/fsck_msdosfs/dir.cSun Sep 15 19:41:54 2019
(r352364)
@@ -317,7 +317,8 @@ delete(int f, struct bootblock *boot, struct fatEntry 
break;
e = delbuf + endoff;
}
-   off = startcl * boot->bpbSecPerClust + boot->ClusterOffset;
+   off = (startcl - CLUST_FIRST) * boot->bpbSecPerClust + 
boot->FirstCluster;
+
off *= boot->bpbBytesPerSec;
if (lseek(f, off, SEEK_SET) != off) {
perr("Unable to lseek to %" PRId64, off);
@@ -457,7 +458,7 @@ check_subdirectory(int f, struct bootblock *boot, stru
off = boot->bpbResSectors + boot->bpbFATs *
boot->FATsecs;
} else {
-   off = cl * boot->bpbSecPerClust + boot->ClusterOffset;
+   off = (cl - CLUST_FIRST) * boot->bpbSecPerClust + 
boot->FirstCluster;
}
 
/*
@@ -538,7 +539,7 @@ readDosDirSection(int f, struct bootblock *boot, struc
boot->FATsecs;
} else {
last = boot->bpbSecPerClust * boot->bpbBytesPerSec;
-   off = cl * boot->bpbSecPerClust + boot->ClusterOffset;
+   off = (cl - CLUST_FIRST) * boot->bpbSecPerClust + 
boot->FirstCluster;
}
 
off *= boot->bpbBytesPerSec;
@@ -1069,8 +1070,9 @@ reconnect(int dosfs, struct bootblock *boot, struct fa
lfcl = (lostDir->head < boot->NumClusters) ? 
lostDir->head : 0;
return FSERROR;
}
-   lfoff = lfcl * boot->ClusterSize
-   + boot->ClusterOffset * boot->bpbBytesPerSec;
+   lfoff = (lfcl - CLUST_FIRST) * boot->ClusterSize
+   + boot->FirstCluster * boot->bpbBytesPerSec;
+
if (lseek(dosfs, lfoff, SEEK_SET) != lfoff
|| (size_t)read(dosfs, lfbuf, boot->ClusterSize) != 
boot->ClusterSize) {
perr("could not read LOST.DIR");

Modified: head/sbin/fsck_msdosfs/dosfs.h
==
--- head/sbin/fsck_msdosfs/dosfs.h  Sun Sep 15 19:38:15 2019
(r352363)
+++ head/sbin/fsck_msdosfs/dosfs.h  Sun Sep 15 19:41:54 2019
(r352364)
@@ -74,7 +74,7 @@ struct bootblock {
u_int32_t NumSectors;   /* how many sectors are there */
u_int32_t FATsecs;  /* how many sectors are in FAT */
u_int32_t NumFatEntries;/* how many entries really are there */
-   u_int   ClusterOffset;  /* at what sector would sector 0 start 
*/
+   u_int   FirstCluster;   /* at what sector is Cluster 
CLUST_FIRST */
u_int   ClusterSize;/* Cluster size in bytes */
 
/* Now some statistics: */
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd

svn commit: r351802 - head/sbin/fsck_msdosfs

2019-09-03 Thread Xin LI
Author: delphij
Date: Wed Sep  4 04:44:03 2019
New Revision: 351802
URL: https://svnweb.freebsd.org/changeset/base/351802

Log:
  Correct overflow logic in fullpath().
  
  Obtained from:OpenBSD
  MFC after:3 days

Modified:
  head/sbin/fsck_msdosfs/dir.c

Modified: head/sbin/fsck_msdosfs/dir.c
==
--- head/sbin/fsck_msdosfs/dir.cWed Sep  4 04:38:31 2019
(r351801)
+++ head/sbin/fsck_msdosfs/dir.cWed Sep  4 04:44:03 2019
(r351802)
@@ -169,20 +169,24 @@ fullpath(struct dosDirEntry *dir)
char *cp, *np;
int nl;
 
-   cp = namebuf + sizeof namebuf - 1;
-   *cp = '\0';
-   do {
+   cp = namebuf + sizeof namebuf;
+   *--cp = '\0';
+
+   for(;;) {
np = dir->lname[0] ? dir->lname : dir->name;
nl = strlen(np);
-   if ((cp -= nl) <= namebuf + 1)
+   if (cp <= namebuf + 1 + nl) {
+   *--cp = '?';
break;
+   }
+   cp -= nl;
memcpy(cp, np, nl);
+   dir = dir->parent;
+   if (!dir)
+   break;
*--cp = '/';
-   } while ((dir = dir->parent) != NULL);
-   if (dir)
-   *--cp = '?';
-   else
-   cp++;
+   }
+
return cp;
 }
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r346220 - head/sbin/fsck_msdosfs

2019-09-03 Thread Xin LI
Author: delphij
Date: Mon Apr 15 06:33:05 2019
New Revision: 346220
URL: https://svnweb.freebsd.org/changeset/base/346220

Log:
  Don't cast result from malloc().
  
  MFC after:2 weeks

Modified:
  head/sbin/fsck_msdosfs/dir.c

Modified: head/sbin/fsck_msdosfs/dir.c
==
--- head/sbin/fsck_msdosfs/dir.cMon Apr 15 03:32:01 2019
(r346219)
+++ head/sbin/fsck_msdosfs/dir.cMon Apr 15 06:33:05 2019
(r346220)
@@ -115,7 +115,7 @@ newDosDirEntry(void)
struct dosDirEntry *de;
 
if (!(de = freede)) {
-   if (!(de = (struct dosDirEntry *)malloc(sizeof *de)))
+   if (!(de = malloc(sizeof *de)))
return 0;
} else
freede = de->next;
@@ -140,7 +140,7 @@ newDirTodo(void)
struct dirTodoNode *dt;
 
if (!(dt = freedt)) {
-   if (!(dt = (struct dirTodoNode *)malloc(sizeof *dt)))
+   if (!(dt = malloc(sizeof *dt)))
return 0;
} else
freedt = dt->next;


___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r346147 - stable/11/sbin/fsck_msdosfs

2019-09-03 Thread Xin LI
Author: delphij
Date: Fri Apr 12 02:27:03 2019
New Revision: 346147
URL: https://svnweb.freebsd.org/changeset/base/346147

Log:
  MFC r345647:
  
  Distinguish between lseek errors and read errores.

Modified:
  stable/11/sbin/fsck_msdosfs/dir.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sbin/fsck_msdosfs/dir.c
==
--- stable/11/sbin/fsck_msdosfs/dir.c   Fri Apr 12 02:24:06 2019
(r346146)
+++ stable/11/sbin/fsck_msdosfs/dir.c   Fri Apr 12 02:27:03 2019
(r346147)
@@ -35,6 +35,7 @@ static const char rcsid[] =
   "$FreeBSD$";
 #endif /* not lint */
 
+#include 
 #include 
 #include 
 #include 
@@ -329,8 +330,11 @@ delete(int f, struct bootblock *boot, struct fatEntry 
}
off = startcl * boot->bpbSecPerClust + boot->ClusterOffset;
off *= boot->bpbBytesPerSec;
-   if (lseek(f, off, SEEK_SET) != off
-   || read(f, delbuf, clsz) != clsz) {
+   if (lseek(f, off, SEEK_SET) != off) {
+   perr("Unable to lseek to %" PRId64, off);
+   return FSFATAL;
+   }
+   if (read(f, delbuf, clsz) != clsz) {
perr("Unable to read directory");
return FSFATAL;
}
@@ -338,8 +342,11 @@ delete(int f, struct bootblock *boot, struct fatEntry 
*s = SLOT_DELETED;
s += 32;
}
-   if (lseek(f, off, SEEK_SET) != off
-   || write(f, delbuf, clsz) != clsz) {
+   if (lseek(f, off, SEEK_SET) != off) {
+   perr("Unable to lseek to %" PRId64, off);
+   return FSFATAL;
+   }
+   if (write(f, delbuf, clsz) != clsz) {
perr("Unable to write directory");
return FSFATAL;
}


___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r346146 - stable/12/sbin/fsck_msdosfs

2019-09-03 Thread Xin LI
Author: delphij
Date: Fri Apr 12 02:24:06 2019
New Revision: 346146
URL: https://svnweb.freebsd.org/changeset/base/346146

Log:
  MFC r345647:
  
  Distinguish between lseek errors and read errores.

Modified:
  stable/12/sbin/fsck_msdosfs/dir.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sbin/fsck_msdosfs/dir.c
==
--- stable/12/sbin/fsck_msdosfs/dir.c   Fri Apr 12 01:03:00 2019
(r346145)
+++ stable/12/sbin/fsck_msdosfs/dir.c   Fri Apr 12 02:24:06 2019
(r346146)
@@ -35,6 +35,7 @@ static const char rcsid[] =
   "$FreeBSD$";
 #endif /* not lint */
 
+#include 
 #include 
 #include 
 #include 
@@ -329,8 +330,11 @@ delete(int f, struct bootblock *boot, struct fatEntry 
}
off = startcl * boot->bpbSecPerClust + boot->ClusterOffset;
off *= boot->bpbBytesPerSec;
-   if (lseek(f, off, SEEK_SET) != off
-   || read(f, delbuf, clsz) != clsz) {
+   if (lseek(f, off, SEEK_SET) != off) {
+   perr("Unable to lseek to %" PRId64, off);
+   return FSFATAL;
+   }
+   if (read(f, delbuf, clsz) != clsz) {
perr("Unable to read directory");
return FSFATAL;
}
@@ -338,8 +342,11 @@ delete(int f, struct bootblock *boot, struct fatEntry 
*s = SLOT_DELETED;
s += 32;
}
-   if (lseek(f, off, SEEK_SET) != off
-   || write(f, delbuf, clsz) != clsz) {
+   if (lseek(f, off, SEEK_SET) != off) {
+   perr("Unable to lseek to %" PRId64, off);
+   return FSFATAL;
+   }
+   if (write(f, delbuf, clsz) != clsz) {
perr("Unable to write directory");
return FSFATAL;
}


___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r345900 - head/sbin/fsck_msdosfs

2019-09-03 Thread Xin LI
On Fri, Apr 5, 2019 at 12:56 PM Hans Petter Selasky  wrote:

> On 4/5/19 9:51 PM, Conrad Meyer wrote:
> > static const u_char dot_name[11] = ".  ";
> > static const u_char dotdot_name[11] = ".. ";
> >
> > Seems more clear to me.
>
> Using this syntax will include a terminating zero.
>

No, that only applies when the length is omitted (char foo[] = "string"
would have \0, but foo[sizeof("string") -1] = "string" won't).

Cheers,



>
> --HPS
>
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r345976 - head/sbin/fsck_msdosfs

2019-09-03 Thread Xin LI
Author: delphij
Date: Sat Apr  6 03:42:15 2019
New Revision: 345976
URL: https://svnweb.freebsd.org/changeset/base/345976

Log:
  Write string constant differently to improve readability.
  
  Reported by:  rgrimes
  Reviewed by:  rgrimes, emaste
  MFC after:13 days
  Differential Revision:https://reviews.freebsd.org/D19829

Modified:
  head/sbin/fsck_msdosfs/dir.c

Modified: head/sbin/fsck_msdosfs/dir.c
==
--- head/sbin/fsck_msdosfs/dir.cSat Apr  6 02:39:56 2019
(r345975)
+++ head/sbin/fsck_msdosfs/dir.cSat Apr  6 03:42:15 2019
(r345976)
@@ -444,10 +444,8 @@ checksize(struct bootblock *boot, struct fatEntry *fat
return FSOK;
 }
 
-static const u_char dot_name[] = {
-   '.', ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ' };
-static const u_char dotdot_name[] = {
-   '.', '.',' ',' ',' ',' ',' ',' ',' ',' ',' ' };
+static const u_char dot_name[11]= ".  ";
+static const u_char dotdot_name[11] = ".. ";
 
 /*
  * Basic sanity check if the subdirectory have good '.' and '..' entries,


___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r345894 - head/sbin/fsck_msdosfs

2019-09-03 Thread Xin LI
Author: delphij
Date: Thu Apr  4 23:16:36 2019
New Revision: 345894
URL: https://svnweb.freebsd.org/changeset/base/345894

Log:
  Restore the ability of checking and fixing next free
  cluster in FSINFO that was lost in r203872.
  
  Obtained from:NetBSD
  MFC after:2 weeks

Modified:
  head/sbin/fsck_msdosfs/fat.c

Modified: head/sbin/fsck_msdosfs/fat.c
==
--- head/sbin/fsck_msdosfs/fat.cThu Apr  4 20:34:17 2019
(r345893)
+++ head/sbin/fsck_msdosfs/fat.cThu Apr  4 23:16:36 2019
(r345894)
@@ -705,6 +705,20 @@ checklost(int dosfs, struct bootblock *boot, struct fa
ret = 1;
}
}
+   if (boot->FSNext != 0xU &&
+   (boot->FSNext >= boot->NumClusters ||
+   (boot->NumFree && fat[boot->FSNext].next != CLUST_FREE))) {
+   pwarn("Next free cluster in FSInfo block (%u) %s\n",
+ boot->FSNext,
+ (boot->FSNext >= boot->NumClusters) ? "invalid" : 
"not free");
+   if (ask(1, "fix"))
+   for (head = CLUST_FIRST; head < 
boot->NumClusters; head++)
+   if (fat[head].next == CLUST_FREE) {
+   boot->FSNext = head;
+   ret = 1;
+   break;
+   }
+   }
if (ret)
mod |= writefsinfo(dosfs, boot);
}


___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r345900 - head/sbin/fsck_msdosfs

2019-09-03 Thread Xin LI
Author: delphij
Date: Fri Apr  5 02:21:16 2019
New Revision: 345900
URL: https://svnweb.freebsd.org/changeset/base/345900

Log:
  Implement checking of `.' and `..' entries of subdirectory.
  
  Reviewed by:  pfg
  Obtained from:Android 
https://android.googlesource.com/platform/external/fsck_msdos/+/b6ee08aadb580341a4d80943741b80de16a88b5d%5E%21/
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D19824

Modified:
  head/sbin/fsck_msdosfs/dir.c

Modified: head/sbin/fsck_msdosfs/dir.c
==
--- head/sbin/fsck_msdosfs/dir.cFri Apr  5 01:22:30 2019
(r345899)
+++ head/sbin/fsck_msdosfs/dir.cFri Apr  5 02:21:16 2019
(r345900)
@@ -444,7 +444,78 @@ checksize(struct bootblock *boot, struct fatEntry *fat
return FSOK;
 }
 
+static const u_char dot_name[] = {
+   '.', ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ' };
+static const u_char dotdot_name[] = {
+   '.', '.',' ',' ',' ',' ',' ',' ',' ',' ',' ' };
+
 /*
+ * Basic sanity check if the subdirectory have good '.' and '..' entries,
+ * and they are directory entries.  Further sanity checks are performed
+ * when we traverse into it.
+ */
+static int
+check_subdirectory(int f, struct bootblock *boot, struct dosDirEntry *dir)
+{
+   u_char *buf, *cp;
+   off_t off;
+   cl_t cl;
+   int retval = FSOK;
+
+   cl = dir->head;
+   if (dir->parent && (cl < CLUST_FIRST || cl >= boot->NumClusters)) {
+   return FSERROR;
+   }
+
+   if (!(boot->flags & FAT32) && !dir->parent) {
+   off = boot->bpbResSectors + boot->bpbFATs *
+   boot->FATsecs;
+   } else {
+   off = cl * boot->bpbSecPerClust + boot->ClusterOffset;
+   }
+
+   /*
+* We only need to check the first two entries of the directory,
+* which is found in the first sector of the directory entry,
+* so read in only the first sector.
+*/
+   buf = malloc(boot->bpbBytesPerSec);
+   if (buf == NULL) {
+   perr("No space for directory buffer (%u)",
+   boot->bpbBytesPerSec);
+   return FSFATAL;
+   }
+
+   off *= boot->bpbBytesPerSec;
+   if (lseek(f, off, SEEK_SET) != off ||
+   read(f, buf, boot->bpbBytesPerSec) != boot->bpbBytesPerSec) {
+   perr("Unable to read directory");
+   free(buf);
+   return FSFATAL;
+   }
+
+   /*
+* Both `.' and `..' must be present and be the first two entries
+* and be ATTR_DIRECTORY of a valid subdirectory.
+*/
+   cp = buf;
+   if (memcmp(cp, dot_name, sizeof(dot_name)) != 0 ||
+   (cp[11] & ATTR_DIRECTORY) != ATTR_DIRECTORY) {
+   pwarn("%s: Incorrect `.' for %s.\n", __func__, dir->name);
+   retval |= FSERROR;
+   }
+   cp += 32;
+   if (memcmp(cp, dotdot_name, sizeof(dotdot_name)) != 0 ||
+   (cp[11] & ATTR_DIRECTORY) != ATTR_DIRECTORY) {
+   pwarn("%s: Incorrect `..' for %s. \n", __func__, dir->name);
+   retval |= FSERROR;
+   }
+
+   free(buf);
+   return retval;
+}
+
+/*
  * Read a directory and
  *   - resolve long name records
  *   - enter file and directory records into the parent's list
@@ -491,9 +562,6 @@ readDosDirSection(int f, struct bootblock *boot, struc
return FSFATAL;
}
last /= 32;
-   /*
-* Check `.' and `..' entries here? XXX
-*/
for (p = buffer, i = 0; i < last; i++, p += 32) {
if (dir->fsckflags & DIREMPWARN) {
*p = SLOT_EMPTY;
@@ -830,6 +898,36 @@ readDosDirSection(int f, struct bootblock *boot, struc
}
}
continue;
+   } else {
+   /*
+* Only one directory entry can point
+* to dir->head, it's '.'.
+*/
+   if (dirent.head == dir->head) {
+   pwarn("%s entry in %s has 
incorrect start cluster\n",
+   dirent.name, 
fullpath(dir));
+   if (ask(1, "Remove")) {
+   *p = SLOT_DELETED;
+   mod |= THISMOD|FSDIRMOD;
+   } else
+   mod |= FSERROR;
+   

svn commit: r345897 - head/sbin/fsck_msdosfs

2019-09-03 Thread Xin LI
Author: delphij
Date: Thu Apr  4 23:34:03 2019
New Revision: 345897
URL: https://svnweb.freebsd.org/changeset/base/345897

Log:
  Restore lfcl when LOSTDIR's chain was corrupted and overwritten
  with invalid value.
  
  Obtained from:Android 
https://android.googlesource.com/platform/external/fsck_msdos/+/4d6d6f8a3674ad67f970e2ae908d34f64e4854cf%5E%21/
  MFC after:2 weeks

Modified:
  head/sbin/fsck_msdosfs/dir.c

Modified: head/sbin/fsck_msdosfs/dir.c
==
--- head/sbin/fsck_msdosfs/dir.cThu Apr  4 23:32:27 2019
(r345896)
+++ head/sbin/fsck_msdosfs/dir.cThu Apr  4 23:34:03 2019
(r345897)
@@ -973,6 +973,7 @@ reconnect(int dosfs, struct bootblock *boot, struct fa
if (lfcl < CLUST_FIRST || lfcl >= boot->NumClusters) {
/* Extend LOSTDIR?  XXX */
pwarn("No space in %s\n", LOSTDIR);
+   lfcl = (lostDir->head < boot->NumClusters) ? 
lostDir->head : 0;
return FSERROR;
}
lfoff = lfcl * boot->ClusterSize


___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r345901 - head/sbin/fsck_msdosfs

2019-09-03 Thread Xin LI
Author: delphij
Date: Fri Apr  5 02:37:10 2019
New Revision: 345901
URL: https://svnweb.freebsd.org/changeset/base/345901

Log:
  Fix build.
  
  MFC after:2 weeks
  X-MFC-With:   r345900

Modified:
  head/sbin/fsck_msdosfs/dir.c

Modified: head/sbin/fsck_msdosfs/dir.c
==
--- head/sbin/fsck_msdosfs/dir.cFri Apr  5 02:21:16 2019
(r345900)
+++ head/sbin/fsck_msdosfs/dir.cFri Apr  5 02:37:10 2019
(r345901)
@@ -488,7 +488,7 @@ check_subdirectory(int f, struct bootblock *boot, stru
 
off *= boot->bpbBytesPerSec;
if (lseek(f, off, SEEK_SET) != off ||
-   read(f, buf, boot->bpbBytesPerSec) != boot->bpbBytesPerSec) {
+   read(f, buf, boot->bpbBytesPerSec) != 
(ssize_t)boot->bpbBytesPerSec) {
perr("Unable to read directory");
free(buf);
return FSFATAL;


___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r345839 - head/sbin/fsck_msdosfs

2019-09-03 Thread Xin LI
Author: delphij
Date: Wed Apr  3 07:09:28 2019
New Revision: 345839
URL: https://svnweb.freebsd.org/changeset/base/345839

Log:
  Assert that q can't be NULL.  'empty' is always non-NULL when DIREMPTY
  is set earlier.
  
  MFC after:1 month

Modified:
  head/sbin/fsck_msdosfs/dir.c

Modified: head/sbin/fsck_msdosfs/dir.c
==
--- head/sbin/fsck_msdosfs/dir.cWed Apr  3 06:37:25 2019
(r345838)
+++ head/sbin/fsck_msdosfs/dir.cWed Apr  3 07:09:28 2019
(r345839)
@@ -35,6 +35,7 @@ static const char rcsid[] =
   "$FreeBSD$";
 #endif /* not lint */
 
+#include 
 #include 
 #include 
 #include 
@@ -520,7 +521,8 @@ readDosDirSection(int f, struct bootblock *boot, struc
   empcl, empty - 
buffer,
   cl, p - buffer, 1) 
== FSFATAL)
return FSFATAL;
-   q = empcl == cl ? empty : 
buffer;
+   q = ((empcl == cl) ? empty : 
buffer);
+   assert(q != NULL);
for (; q < p; q += 32)
*q = SLOT_DELETED;
mod |= THISMOD|FSDIRMOD;


___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r345647 - head/sbin/fsck_msdosfs

2019-09-03 Thread Xin LI
Author: delphij
Date: Thu Mar 28 18:20:47 2019
New Revision: 345647
URL: https://svnweb.freebsd.org/changeset/base/345647

Log:
  Distinguish between lseek errors and read errores.
  
  MFC after:2 weeks

Modified:
  head/sbin/fsck_msdosfs/dir.c

Modified: head/sbin/fsck_msdosfs/dir.c
==
--- head/sbin/fsck_msdosfs/dir.cThu Mar 28 17:30:47 2019
(r345646)
+++ head/sbin/fsck_msdosfs/dir.cThu Mar 28 18:20:47 2019
(r345647)
@@ -35,6 +35,7 @@ static const char rcsid[] =
   "$FreeBSD$";
 #endif /* not lint */
 
+#include 
 #include 
 #include 
 #include 
@@ -329,8 +330,11 @@ delete(int f, struct bootblock *boot, struct fatEntry 
}
off = startcl * boot->bpbSecPerClust + boot->ClusterOffset;
off *= boot->bpbBytesPerSec;
-   if (lseek(f, off, SEEK_SET) != off
-   || read(f, delbuf, clsz) != clsz) {
+   if (lseek(f, off, SEEK_SET) != off) {
+   perr("Unable to lseek to %" PRId64, off);
+   return FSFATAL;
+   }
+   if (read(f, delbuf, clsz) != clsz) {
perr("Unable to read directory");
return FSFATAL;
}
@@ -338,8 +342,11 @@ delete(int f, struct bootblock *boot, struct fatEntry 
*s = SLOT_DELETED;
s += 32;
}
-   if (lseek(f, off, SEEK_SET) != off
-   || write(f, delbuf, clsz) != clsz) {
+   if (lseek(f, off, SEEK_SET) != off) {
+   perr("Unable to lseek to %" PRId64, off);
+   return FSFATAL;
+   }
+   if (write(f, delbuf, clsz) != clsz) {
perr("Unable to write directory");
return FSFATAL;
}


___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r351737 - stable/12/sbin/fsck_msdosfs

2019-09-03 Thread Xin LI
Author: delphij
Date: Tue Sep  3 07:02:18 2019
New Revision: 351737
URL: https://svnweb.freebsd.org/changeset/base/351737

Log:
  MFC r351205: Use calloc().

Modified:
  stable/12/sbin/fsck_msdosfs/fat.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sbin/fsck_msdosfs/fat.c
==
--- stable/12/sbin/fsck_msdosfs/fat.c   Tue Sep  3 07:02:02 2019
(r351736)
+++ stable/12/sbin/fsck_msdosfs/fat.c   Tue Sep  3 07:02:18 2019
(r351737)
@@ -54,10 +54,10 @@ static int _readfat(int, struct bootblock *, u_int, u_
  * 31..   ...0
  *     FAT32 entry 0
  * sh11   1xxx FAT32 entry 1
- * 
+ *
  *     FAT16 entry 0
  *   sh11 1xxx FAT16 entry 1
- * 
+ *
  * r = reserved
  * m = BPB media ID byte
  * s = clean flag (1 = dismounted; 0 = still mounted)
@@ -166,11 +166,11 @@ static int
 _readfat(int fs, struct bootblock *boot, u_int no, u_char **buffer)
 {
off_t off;
-   size_t len;
 
-   *buffer = malloc(len = boot->FATsecs * boot->bpbBytesPerSec);
+   *buffer = calloc(boot->FATsecs, boot->bpbBytesPerSec);
if (*buffer == NULL) {
-   perr("No space for FAT sectors (%zu)", len);
+   perr("No space for FAT sectors (%zu)",
+   (size_t)boot->FATsecs);
return 0;
}
 
@@ -205,20 +205,19 @@ readfat(int fs, struct bootblock *boot, u_int no, stru
u_char *buffer, *p;
cl_t cl;
int ret = FSOK;
-   size_t len;
 
boot->NumFree = boot->NumBad = 0;
 
if (!_readfat(fs, boot, no, &buffer))
return FSFATAL;
 
-   fat = malloc(len = boot->NumClusters * sizeof(struct fatEntry));
+   fat = calloc(boot->NumClusters, sizeof(struct fatEntry));
if (fat == NULL) {
-   perr("No space for FAT clusters (%zu)", len);
+   perr("No space for FAT clusters (%zu)",
+   (size_t)boot->NumClusters);
free(buffer);
return FSFATAL;
}
-   (void)memset(fat, 0, len);
 
if (buffer[0] != boot->bpbMedia
|| buffer[1] != 0xff || buffer[2] != 0xff
@@ -566,12 +565,13 @@ writefat(int fs, struct bootblock *boot, struct fatEnt
off_t off;
int ret = FSOK;
 
-   buffer = malloc(fatsz = boot->FATsecs * boot->bpbBytesPerSec);
+   fatsz = boot->FATsecs * boot->bpbBytesPerSec;
+   buffer = calloc(boot->FATsecs, boot->bpbBytesPerSec);
if (buffer == NULL) {
-   perr("No space for FAT sectors (%zu)", fatsz);
+   perr("No space for FAT sectors (%zu)",
+   (size_t)boot->FATsecs);
return FSFATAL;
}
-   memset(buffer, 0, fatsz);
boot->NumFree = 0;
p = buffer;
if (correct_fat) {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r351735 - stable/12/sbin/fsck_msdosfs

2019-09-02 Thread Xin LI
Author: delphij
Date: Tue Sep  3 06:52:21 2019
New Revision: 351735
URL: https://svnweb.freebsd.org/changeset/base/351735

Log:
  MFC r351204:
  
  Remove redundant check and wrong fix: fat.c checks already take care
  about cluster chains.
  
  Obtained from:OpenBSD

Modified:
  stable/12/sbin/fsck_msdosfs/dir.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sbin/fsck_msdosfs/dir.c
==
--- stable/12/sbin/fsck_msdosfs/dir.c   Tue Sep  3 06:41:19 2019
(r351734)
+++ stable/12/sbin/fsck_msdosfs/dir.c   Tue Sep  3 06:52:21 2019
(r351735)
@@ -219,7 +219,6 @@ int
 resetDosDirSection(struct bootblock *boot, struct fatEntry *fat)
 {
int b1, b2;
-   cl_t cl;
int ret = FSOK;
size_t len;
 
@@ -252,24 +251,9 @@ resetDosDirSection(struct bootblock *boot, struct fatE
   boot->bpbRootClust);
return FSFATAL;
}
-   cl = fat[boot->bpbRootClust].next;
-   if (cl < CLUST_FIRST
-   || (cl >= CLUST_RSRVD && cl< CLUST_EOFS)
-   || fat[boot->bpbRootClust].head != boot->bpbRootClust) {
-   if (cl == CLUST_FREE)
-   pwarn("Root directory starts with free 
cluster\n");
-   else if (cl >= CLUST_RSRVD)
-   pwarn("Root directory starts with cluster 
marked %s\n",
- rsrvdcltype(cl));
-   else {
-   pfatal("Root directory doesn't start a cluster 
chain");
-   return FSFATAL;
-   }
-   if (ask(1, "Fix")) {
-   fat[boot->bpbRootClust].next = CLUST_FREE;
-   ret = FSFATMOD;
-   } else
-   ret = FSFATAL;
+   if (fat[boot->bpbRootClust].head != boot->bpbRootClust) {
+   pfatal("Root directory doesn't start a cluster chain");
+   return FSFATAL;
}
 
fat[boot->bpbRootClust].flags |= FAT_USED;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r351623 - head/sbin/fsck_msdosfs

2019-08-29 Thread Xin LI
Author: delphij
Date: Fri Aug 30 06:06:12 2019
New Revision: 351623
URL: https://svnweb.freebsd.org/changeset/base/351623

Log:
  Remove unneeded blank line.  No functional change.
  
  MFC after:2 weeks

Modified:
  head/sbin/fsck_msdosfs/fat.c

Modified: head/sbin/fsck_msdosfs/fat.c
==
--- head/sbin/fsck_msdosfs/fat.cFri Aug 30 00:45:53 2019
(r351622)
+++ head/sbin/fsck_msdosfs/fat.cFri Aug 30 06:06:12 2019
(r351623)
@@ -518,7 +518,6 @@ clear:
}
if (head == fat[n].head) {
pwarn("Cluster chain starting at %u loops at cluster 
%u\n",
-   
head, p);
goto clear;
}
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r351502 - head/sbin/fsck_msdosfs

2019-08-25 Thread Xin LI
Author: delphij
Date: Mon Aug 26 06:41:17 2019
New Revision: 351502
URL: https://svnweb.freebsd.org/changeset/base/351502

Log:
  Comment boot block checks and perform additional sanity checks:
  
  The following checks are now being enforced:
  
   - bpbBytesPerSec: only accept 512, 1024, 2048 and 4096.
   - bpbSecPerClust: only accept 1, 2, 4, 8, 16, 32, 64 and 128.
   - bpbResSectors: require non-zero.
   - bpbFATs: require non-zero.
   - bpbSectors: require zero for FAT32.
   - bpbFATsmall: require zero for FAT32.
   - bpbHugeSectors: require non-zero for FAT32.
  
  Bail out if the BPB contained values that do not meet these requirements.
  
  We also require FATsecs * FATsecs to not overflow 32-bit unsigned
  integer.
  
  Check for backup boot block was removed because the checker does not take
  corrective action, and msdosfs driver ignores it too.

Modified:
  head/sbin/fsck_msdosfs/boot.c

Modified: head/sbin/fsck_msdosfs/boot.c
==
--- head/sbin/fsck_msdosfs/boot.c   Mon Aug 26 00:46:39 2019
(r351501)
+++ head/sbin/fsck_msdosfs/boot.c   Mon Aug 26 06:41:17 2019
(r351502)
@@ -33,6 +33,9 @@ static const char rcsid[] =
   "$FreeBSD$";
 #endif /* not lint */
 
+#include 
+
+#include 
 #include 
 #include 
 #include 
@@ -46,9 +49,7 @@ readboot(int dosfs, struct bootblock *boot)
 {
u_char block[DOSBOOTBLOCKSIZE];
u_char fsinfo[2 * DOSBOOTBLOCKSIZE];
-   u_char backup[DOSBOOTBLOCKSIZE];
int ret = FSOK;
-   int i;
 
if ((size_t)read(dosfs, block, sizeof block) != sizeof block) {
perr("could not read boot block");
@@ -64,61 +65,133 @@ readboot(int dosfs, struct bootblock *boot)
memset(boot, 0, sizeof *boot);
boot->ValidFat = -1;
 
-   /* decode bios parameter block */
+   /* Decode BIOS Parameter Block */
+
+   /* Bytes per sector: can only be  512, 1024, 2048 and 4096. */
boot->bpbBytesPerSec = block[11] + (block[12] << 8);
+   if (boot->bpbBytesPerSec < DOSBOOTBLOCKSIZE_REAL ||
+   boot->bpbBytesPerSec > DOSBOOTBLOCKSIZE ||
+   !powerof2(boot->bpbBytesPerSec)) {
+   pfatal("Invalid sector size: %u", boot->bpbBytesPerSec);
+   return FSFATAL;
+   }
+
+   /* Sectors per cluster: can only be: 1, 2, 4, 8, 16, 32, 64, 128. */
boot->bpbSecPerClust = block[13];
+   if (boot->bpbSecPerClust == 0 || !powerof2(boot->bpbSecPerClust)) {
+   pfatal("Invalid cluster size: %u", boot->bpbSecPerClust);
+   return FSFATAL;
+   }
+
+   /* Reserved sectors: must be non-zero */
boot->bpbResSectors = block[14] + (block[15] << 8);
+   if (boot->bpbResSectors < 1) {
+   pfatal("Invalid reserved sectors: %u",
+   boot->bpbResSectors);
+   return FSFATAL;
+   }
+
+   /* Number of FATs */
boot->bpbFATs = block[16];
+   if (boot->bpbFATs == 0) {
+   pfatal("Invalid number of FATs: %u", boot->bpbFATs);
+   return FSFATAL;
+   }
+
+   /* Root directory entries for FAT12 and FAT16 */
boot->bpbRootDirEnts = block[17] + (block[18] << 8);
+   if (!boot->bpbRootDirEnts) {
+   /* bpbRootDirEnts = 0 suggests that we are FAT32 */
+   boot->flags |= FAT32;
+   }
+
+   /* Total sectors (16 bits) */
boot->bpbSectors = block[19] + (block[20] << 8);
+   if (boot->bpbSectors != 0 && (boot->flags & FAT32)) {
+   pfatal("Invalid 16-bit total sector count on FAT32: %u",
+   boot->bpbSectors);
+   return FSFATAL;
+   }
+
+   /* Media type: ignored */
boot->bpbMedia = block[21];
+
+   /* FAT12/FAT16: 16-bit count of sectors per FAT */
boot->bpbFATsmall = block[22] + (block[23] << 8);
+   if (boot->bpbFATsmall != 0 && (boot->flags & FAT32)) {
+   pfatal("Invalid 16-bit FAT sector count on FAT32: %u",
+   boot->bpbFATsmall);
+   return FSFATAL;
+   }
+
+   /* Legacy CHS geometry numbers: ignored */
boot->SecPerTrack = block[24] + (block[25] << 8);
boot->bpbHeads = block[26] + (block[27] << 8);
+
+   /* Hidden sectors: ignored */
boot->bpbHiddenSecs = block[28] + (block[29] << 8) +
(block[30] << 16) + (block[31] << 24);
+
+   /* Total sectors (32 bits) */
boot->bpbHugeSectors = block[32] + (block[33] << 8) +
(block[34] << 16) + (block[35] << 24);
+   if (boot->bpbHugeSectors == 0) {
+   if (boot->flags & FAT32) {
+   pfatal("FAT32 with sector count of zero");
+   return FSFATAL;
+   } else if (boot->bpbSectors == 0) {
+   pfatal("FAT with sector count of zero");
+   return FSFATAL;
+   }
+   boot->NumSect

svn commit: r351501 - head/sys/contrib/zlib

2019-08-25 Thread Xin LI
Author: delphij
Date: Mon Aug 26 00:46:39 2019
New Revision: 351501
URL: https://svnweb.freebsd.org/changeset/base/351501

Log:
  MFV r351500:  Fix CLEAR_HASH macro to be usable as a single statement.
  
  MFC after:2 weeks

Modified:
  head/sys/contrib/zlib/deflate.c
Directory Properties:
  head/sys/contrib/zlib/   (props changed)

Modified: head/sys/contrib/zlib/deflate.c
==
--- head/sys/contrib/zlib/deflate.c Sun Aug 25 23:51:44 2019
(r351500)
+++ head/sys/contrib/zlib/deflate.c Mon Aug 26 00:46:39 2019
(r351501)
@@ -189,9 +189,11 @@ local const config configuration_table[10] = {
  * Initialize the hash table (avoiding 64K overflow for 16 bit systems).
  * prev[] will be initialized on the fly.
  */
-#define CLEAR_HASH(s) do { \
-s->head[s->hash_size-1] = NIL; \
-zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head)); \
+#define CLEAR_HASH(s) \
+do { \
+s->head[s->hash_size-1] = NIL; \
+zmemzero((Bytef *)s->head, \
+ (unsigned)(s->hash_size-1)*sizeof(*s->head)); \
 } while (0)
 
 /* ===
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r351500 - vendor/zlib/dist

2019-08-25 Thread Xin LI
Author: delphij
Date: Sun Aug 25 23:51:44 2019
New Revision: 351500
URL: https://svnweb.freebsd.org/changeset/base/351500

Log:
  Import vendor commit 38e8ce32afbaa82f67d992b9f3056f281fe69259:
Author: Mark Adler 
Date:   Sun Jan 22 23:38:52 2017 -0800
  
  Fix CLEAR_HASH macro to be usable as a single statement.
  
  As it is used in deflateParams().

Modified:
  vendor/zlib/dist/deflate.c

Modified: vendor/zlib/dist/deflate.c
==
--- vendor/zlib/dist/deflate.c  Sun Aug 25 22:30:18 2019(r351499)
+++ vendor/zlib/dist/deflate.c  Sun Aug 25 23:51:44 2019(r351500)
@@ -190,8 +190,11 @@ local const config configuration_table[10] = {
  * prev[] will be initialized on the fly.
  */
 #define CLEAR_HASH(s) \
-s->head[s->hash_size-1] = NIL; \
-zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head));
+do { \
+s->head[s->hash_size-1] = NIL; \
+zmemzero((Bytef *)s->head, \
+ (unsigned)(s->hash_size-1)*sizeof(*s->head)); \
+} while (0)
 
 /* ===
  * Slide the hash table when sliding the window down (could be avoided with 32
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


<    1   2   3   4   5   6   7   8   9   10   >