summaryrefslogtreecommitdiff
path: root/libntp/dolfptoa.c
diff options
context:
space:
mode:
authorOllivier Robert <roberto@FreeBSD.org>2008-08-18 14:26:05 +0000
committerOllivier Robert <roberto@FreeBSD.org>2008-08-18 14:26:05 +0000
commitff717da2cf625e3d07537a93a4c240692fa55bd6 (patch)
tree9dcf618e4446ac2b5fca7d0afe7767382664f0d6 /libntp/dolfptoa.c
parentcce65f439697627afbccf5a67035a957bb4d784a (diff)
Notes
Diffstat (limited to 'libntp/dolfptoa.c')
-rw-r--r--libntp/dolfptoa.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/libntp/dolfptoa.c b/libntp/dolfptoa.c
index 7c92a305aca3..f68679cf000b 100644
--- a/libntp/dolfptoa.c
+++ b/libntp/dolfptoa.c
@@ -36,6 +36,14 @@ dolfptoa(
memset((char *) cbuf, 0, sizeof(cbuf));
/*
+ * safeguard against sign extensions and other mishaps on 64 bit platforms
+ * the code following is designed for and only for 32-bit inputs and
+ * only 32-bit worth of input are supplied.
+ */
+ fpi &= 0xffffffff;
+ fpv &= 0xffffffff;
+
+ /*
* Work on the integral part. This is biased by what I know
* compiles fairly well for a 68000.
*/
@@ -49,6 +57,7 @@ dolfptoa(
ltmp = lwork;
lwork /= lten;
ltmp -= (lwork << 3) + (lwork << 1);
+ if (cp < cbuf) abort(); /* rather die a horrible death than trash the memory */
*--cp = (u_char)ltmp;
} while (lwork & 0xffff0000);
}
@@ -61,6 +70,7 @@ dolfptoa(
stmp = swork;
swork = (u_short) (swork/sten);
stmp = (u_short)(stmp - ((swork<<3) + (swork<<1)));
+ if (cp < cbuf) abort(); /* rather die a horrible death than trash the memory */
*--cp = (u_char)stmp;
} while (swork != 0);
}
@@ -110,6 +120,7 @@ dolfptoa(
*cpend++ = (u_char)work.l_ui;
if (work.l_uf == 0)
break;
+ if (cpend > (cbuf + sizeof(cbuf))) abort(); /* rather die a horrible death than trash the memory */
}
/*