Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: overflow in libsa dosfs, feature for efiboot (patches provided)



On Mon, Jan 20, 2020 at 03:41:33PM -0800, Rob Newberry wrote:

> Below are patches -- one to "dosfs.c" to fix the overflow problem,
> one to "efiblock.c" to add the "deal with no disklabel" feature.  I
> don't know the proper way to propose or advocate for these, but I'm
> sharing them here in the hopes that they'll eventually make it in --
> though surely after some feedback from others.  Thanks for any advice!

I think I dimly recall there was a magic way to just use the default
device efiboot was loaded from w/o any partition magic - but I can't
remember details. Maybe the non-disklabel part is not needed?

Can you try the below patch instead of your first one?

Martin

Index: dosfs.c
===================================================================
RCS file: /cvsroot/src/sys/lib/libsa/dosfs.c,v
retrieving revision 1.22
diff -u -p -r1.22 dosfs.c
--- dosfs.c	31 Mar 2019 20:08:45 -0000	1.22
+++ dosfs.c	21 Jan 2020 07:35:44 -0000
@@ -110,7 +110,7 @@ static const struct direntry dot[2] = {
 
 /* The usual conversion macros to avoid multiplication and division */
 #define bytsec(n)      ((n) >> SSHIFT)
-#define secbyt(s)      ((s) << SSHIFT)
+#define secbyt(s)      ((uint64_t)(s) << SSHIFT)
 #define entsec(e)      ((e) >> DSHIFT)
 #define bytblk(fs, n)  ((n) >> (fs)->bshift)
 #define blkbyt(fs, b)  ((b) << (fs)->bshift)
@@ -146,7 +146,7 @@ static off_t fsize(DOS_FS *, struct dire
 static int fatcnt(DOS_FS *, u_int);
 static int fatget(DOS_FS *, u_int *);
 static int fatend(u_int, u_int);
-static int ioread(DOS_FS *, u_int, void *, u_int);
+static int ioread(DOS_FS *, uint64_t, void *, u_int);
 static int iobuf(DOS_FS *, u_int);
 static int ioget(struct open_file *, u_int, void *, u_int);
 
@@ -733,7 +733,7 @@ fatend(u_int sz, u_int c)
  * Offset-based I/O primitive
  */
 static int
-ioread(DOS_FS *fs, u_int offset, void *buf, u_int nbyte)
+ioread(DOS_FS *fs, uint64_t offset, void *buf, u_int nbyte)
 {
 	char   *s;
 	u_int   off, n;



Home | Main Index | Thread Index | Old Index