summaryrefslogtreecommitdiffstats
path: root/sys/boot/sparc64/boot1
diff options
context:
space:
mode:
authorrobert <robert@FreeBSD.org>2002-03-05 11:22:43 +0000
committerrobert <robert@FreeBSD.org>2002-03-05 11:22:43 +0000
commit29222a8f6715ad5a2ad587c2518981d504d10a0f (patch)
treeadb789b9bdfc4cc14c85b97300c85f1cfc0ac6c4 /sys/boot/sparc64/boot1
parent0c4549952e78c4861dfa355880ec1995f0a1c6ae (diff)
downloadFreeBSD-src-29222a8f6715ad5a2ad587c2518981d504d10a0f.zip
FreeBSD-src-29222a8f6715ad5a2ad587c2518981d504d10a0f.tar.gz
- Fix seeking for offsets requiring more than 32 bits.
- Add sanity checks to lookup(). - Implement the 'l' modifier in printf(). Submitted by: tmm
Diffstat (limited to 'sys/boot/sparc64/boot1')
-rw-r--r--sys/boot/sparc64/boot1/boot1.c32
1 files changed, 27 insertions, 5 deletions
diff --git a/sys/boot/sparc64/boot1/boot1.c b/sys/boot/sparc64/boot1/boot1.c
index 35df35a..0ab2397 100644
--- a/sys/boot/sparc64/boot1/boot1.c
+++ b/sys/boot/sparc64/boot1/boot1.c
@@ -275,7 +275,7 @@ ofw_seek(ofwh_t devh, u_int64_t off)
1,
(u_ofwh_t)devh,
off >> 32,
- off & ((1UL << 32) - 1),
+ off,
0
};
@@ -511,6 +511,8 @@ lookup(const char *path)
ino = ROOTINO;
dt = DT_DIR;
+ name[0] = '/';
+ name[1] = '\0';
for (;;) {
if (*path == '/')
path++;
@@ -523,6 +525,10 @@ lookup(const char *path)
ls = *path == '?' && n == 1 && !*s;
memcpy(name, path, n);
name[n] = 0;
+ if (dt != DT_DIR) {
+ printf("%s: not a directory.\n", name);
+ return (0);
+ }
if ((dt = fsfind(name, &ino)) <= 0)
break;
path = s;
@@ -639,21 +645,29 @@ printf(const char *fmt,...)
char buf[10];
char *s;
unsigned long int r, u;
- int c;
+ int c, longp;
va_start(ap, fmt);
+ longp = 0;
while ((c = *fmt++)) {
- if (c == '%') {
- c = *fmt++;
+ if (c == '%' || longp) {
+ if (c == '%')
+ c = *fmt++;
switch (c) {
case 'c':
+ if (longp)
+ break;
putchar(va_arg(ap, int));
continue;
case 's':
+ if (longp)
+ break;
for (s = va_arg(ap, char *); *s; s++)
putchar(*s);
continue;
case 'p':
+ if (longp)
+ break;
if (c == 'p') {
putchar('0');
putchar('x');
@@ -661,7 +675,8 @@ printf(const char *fmt,...)
case 'u':
case 'x':
r = c == 'u' ? 10U : 16U;
- u = c == 'p' ? va_arg(ap, unsigned long) :
+ u = (c == 'p' || longp) ?
+ va_arg(ap, unsigned long) :
va_arg(ap, unsigned int);
s = buf;
do
@@ -669,8 +684,15 @@ printf(const char *fmt,...)
while (u /= r);
while (--s >= buf)
putchar(*s);
+ longp = 0;
+ continue;
+ case 'l':
+ if (longp)
+ break;
+ longp = 1;
continue;
}
+ longp = 0;
}
putchar(c);
}
OpenPOWER on IntegriCloud