=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/printf/printf.c,v retrieving revision 1.3 retrieving revision 1.4 diff -c -r1.3 -r1.4 *** src/usr.bin/printf/printf.c 1997/01/17 07:13:06 1.3 --- src/usr.bin/printf/printf.c 2000/12/22 22:53:10 1.4 *************** *** 1,4 **** ! /* $OpenBSD: printf.c,v 1.3 1997/01/17 07:13:06 millert Exp $ */ /* * Copyright (c) 1989 The Regents of the University of California. --- 1,4 ---- ! /* $OpenBSD: printf.c,v 1.4 2000/12/22 22:53:10 deraadt Exp $ */ /* * Copyright (c) 1989 The Regents of the University of California. *************** *** 43,49 **** #ifndef lint /*static char sccsid[] = "from: @(#)printf.c 5.9 (Berkeley) 6/1/90";*/ ! static char rcsid[] = "$OpenBSD: printf.c,v 1.3 1997/01/17 07:13:06 millert Exp $"; #endif /* not lint */ #include --- 43,49 ---- #ifndef lint /*static char sccsid[] = "from: @(#)printf.c 5.9 (Berkeley) 6/1/90";*/ ! static char rcsid[] = "$OpenBSD: printf.c,v 1.4 2000/12/22 22:53:10 deraadt Exp $"; #endif /* not lint */ #include *************** *** 221,228 **** } case 'd': case 'i': { char *f = mklong(start, convch); ! long p = getlong(); PF(f, p); break; } --- 221,233 ---- } case 'd': case 'i': { + long p; char *f = mklong(start, convch); ! if (!f) { ! warnx("out of memory"); ! return (1); ! } ! p = getlong(); PF(f, p); break; } *************** *** 230,237 **** case 'u': case 'x': case 'X': { char *f = mklong(start, convch); ! unsigned long p = getulong(); PF(f, p); break; } --- 235,247 ---- case 'u': case 'x': case 'X': { + unsigned long p; char *f = mklong(start, convch); ! if (!f) { ! warnx("out of memory"); ! return (1); ! } ! p = getulong(); PF(f, p); break; } *************** *** 412,421 **** const char *str; char ch; { ! static char copy[64]; int len; len = strlen(str) + 2; (void) memmove(copy, str, len - 3); copy[len - 3] = 'l'; copy[len - 2] = ch; --- 422,445 ---- const char *str; char ch; { ! static char *copy; ! static int copysize; int len; len = strlen(str) + 2; + if (copysize < len) { + char *newcopy; + copysize = len + 256; + + newcopy = realloc(copy, copysize); + if (newcopy == NULL) { + copysize = 0; + free(copy); + copy = NULL; + return (NULL); + } + copy = newcopy; + } (void) memmove(copy, str, len - 3); copy[len - 3] = 'l'; copy[len - 2] = ch;