-/* $OpenBSD: jot.c,v 1.38 2017/12/15 13:04:11 tb Exp $ */
+/* $OpenBSD: jot.c,v 1.39 2017/12/15 14:20:52 tb Exp $ */
/* $NetBSD: jot.c,v 1.3 1994/12/02 20:29:43 pk Exp $ */
/*-
errx(1, "-w word too long");
intdata = true;
} else if (*(p+1) == '\0') {
- if (sz <= 0)
- errx(1, "-w word too long");
/* cannot end in single '%' */
- strlcat(format, "%", sizeof format);
+ if (strlcat(format, "%", sizeof(format)) >= sizeof(format))
+ errx(1, "-w word too long");
} else {
/*
* Allow conversion format specifiers of the form
else if (*p == '%' && *(p+1) == '%')
p++;
else if (*p == '%' && *(p+1) == '\0') {
- strlcat(format, "%", sizeof format);
+ /* cannot end in single '%' */
+ if (strlcat(format, "%", sizeof(format)) >=
+ sizeof(format))
+ errx(1, "-w word too long");
break;
}
}