Bug fix for APM library.
Lloyd Zusman
ljz%fxgrp.fx.com at ames.arc.nasa.gov
Fri Oct 21 05:22:26 AEST 1988
Here are the context diffs for a bug fix for the APM library, which
was posted to comp.sources.misc a couple weeks ago. When converting
APM values to ASCII and right justifying, a segment violation could
occur due to a byte copy overflow.
Go to the directory where the APM source code is stored, make sure
that misc.c is writable, and then type 'patch <thisfile'. If you
don't have Larry Wall's "patch" program, you can apply these diffs by
hand ... they aren't all that extensive.
Good luck.
--
Lloyd Zusman Internet: ljz at fx.com
Master Byte Software or ljz%fx.com at ames.arc.nasa.gov
Los Gatos, California or fxgrp!ljz at ames.arc.nasa.gov
"We take things well in hand." uucp: ...!ames!fxgrp!ljz
[ our Internet connection is down: use uucp or mail to the entry above it ]
--------------------------------- cut here ------------------------------------
*** /tmp/,RCSt1a10696 Thu Oct 20 12:10:37 1988
--- misc.c Thu Oct 20 12:09:18 1988
***************
*** 2,13 ****
* Miscellaneous routines for the APM library.
*
* $Log: misc.c,v $
* Revision 1.0 88/10/05 12:38:14 ljz
* Initial release.
*
*/
#ifndef lint
! static char rcsid[] = "$Header: misc.c,v 1.0 88/10/05 12:38:14 ljz Exp $";
#endif /* ! lint */
#include <stdio.h>
--- 2,16 ----
* Miscellaneous routines for the APM library.
*
* $Log: misc.c,v $
+ * Revision 1.1 88/10/20 10:45:15 ljz
+ * Fixed byte copy overflow in apm_convert.
+ *
* Revision 1.0 88/10/05 12:38:14 ljz
* Initial release.
*
*/
#ifndef lint
! static char rcsid[] = "$Header: misc.c,v 1.1 88/10/20 10:45:15 ljz Exp $";
#endif /* ! lint */
#include <stdio.h>
***************
*** 192,197 ****
--- 195,201 ----
static int localLen = 0;
int roffset;
int loffset;
+ int copylength;
int stringlen;
int dpos = -1;
int n;
***************
*** 315,334 ****
roffset = 0;
loffset = 0;
if (length > stringlen) {
! length = stringlen;
}
}
else if (stringlen >= length) {
roffset = 0;
loffset = stringlen - length;
}
else {
roffset = length - stringlen;
loffset = 0;
}
! APM_copy_bytes(result + roffset, localString + loffset, length);
! result[length] = '\0';
while (roffset-- > 0) {
result[roffset] = ' ';
}
--- 319,343 ----
roffset = 0;
loffset = 0;
if (length > stringlen) {
! copylength = stringlen;
}
+ else {
+ copylength = length;
+ }
}
else if (stringlen >= length) {
roffset = 0;
loffset = stringlen - length;
+ copylength = length;
}
else {
roffset = length - stringlen;
loffset = 0;
+ copylength = stringlen;
}
! APM_copy_bytes(result + roffset, localString + loffset, copylength);
! result[copylength] = '\0';
while (roffset-- > 0) {
result[roffset] = ' ';
}
More information about the Comp.sources.bugs
mailing list