sprintf -> snprintf

From: Bruno Rohee <bruno at rohee dot com>
This commit is contained in:
brad 2005-04-03 23:26:22 +00:00
parent a61f5f1f4b
commit a2563cef31
3 changed files with 42 additions and 2 deletions

View File

@ -1,9 +1,9 @@
# $OpenBSD: Makefile,v 1.25 2004/11/30 01:06:36 espie Exp $
# $OpenBSD: Makefile,v 1.26 2005/04/03 23:26:22 brad Exp $
COMMENT= "IJG's JPEG compression utilities"
DISTNAME= jpegsrc.v6b
PKGNAME= jpeg-6b
PKGNAME= jpeg-6bp1
CATEGORIES= graphics
MASTER_SITES= ftp://ftp.uu.net/graphics/jpeg/ \
ftp://ftp.shellhung.org/pub/Mirror/enlightenment/enlightenment/libs/

View File

@ -0,0 +1,24 @@
$OpenBSD: patch-jerror_c,v 1.1 2005/04/03 23:26:22 brad Exp $
This one is slightly problematic, if an application
choose to allocate more room for its error buffer than
the recommanded JMSG_LENGTH_MAX the error message will
get truncated.
There should be no loss of functionnality and I'm not
aware of any app doing that.
--- jerror.c.orig Sun Feb 22 02:03:15 1998
+++ jerror.c Sun Mar 27 04:01:51 2005
@@ -190,9 +190,9 @@ format_message (j_common_ptr cinfo, char
/* Format the message into the passed buffer */
if (isstring)
- sprintf(buffer, msgtext, err->msg_parm.s);
+ snprintf(buffer, JMSG_LENGTH_MAX, msgtext, err->msg_parm.s);
else
- sprintf(buffer, msgtext,
+ snprintf(buffer, JMSG_LENGTH_MAX, msgtext,
err->msg_parm.i[0], err->msg_parm.i[1],
err->msg_parm.i[2], err->msg_parm.i[3],
err->msg_parm.i[4], err->msg_parm.i[5],

View File

@ -0,0 +1,16 @@
$OpenBSD: patch-wrrle_c,v 1.1 2005/04/03 23:26:22 brad Exp $
cmapcomment is a local array, we can use sizeof.
--- wrrle.c.orig Sun Mar 27 03:48:15 2005
+++ wrrle.c Sun Mar 27 03:49:32 2005
@@ -199,7 +199,8 @@ finish_output_rle (j_decompress_ptr cinf
header.cmaplen = CMAPBITS;
header.cmap = dest->colormap;
/* Add a comment to the output image with the true colormap length. */
- sprintf(cmapcomment, "color_map_length=%d", cinfo->actual_number_of_colors);
+ snprintf(cmapcomment, sizeof cmapcomment,
+ "color_map_length=%d", cinfo->actual_number_of_colors);
rle_putcom(cmapcomment, &header);
}