|
From: <and...@us...> - 2009-02-08 22:34:29
|
Revision: 9477
http://plplot.svn.sourceforge.net/plplot/?rev=9477&view=rev
Author: andrewross
Date: 2009-02-08 22:34:26 +0000 (Sun, 08 Feb 2009)
Log Message:
-----------
strncat specifies the maximum number of characters to add to the destination string, not
the total length of the destination string. It will be null-terminated though.
Modified Paths:
--------------
trunk/src/plcont.c
trunk/src/plfreetype.c
trunk/src/plmap.c
Modified: trunk/src/plcont.c
===================================================================
--- trunk/src/plcont.c 2009-02-08 22:26:44 UTC (rev 9476)
+++ trunk/src/plcont.c 2009-02-08 22:34:26 UTC (rev 9477)
@@ -354,7 +354,7 @@
snprintf(form, FORM_LEN, "%%.%df", prec-1);
snprintf(string, len, form, mant);
snprintf(tmpstring, TMPSTRING_LEN, "#(229)10#u%d", exponent);
- strncat(string, tmpstring, len);
+ strncat(string, tmpstring, len-strlen(string)-1);
if (abs(exponent) < limexp || value == 0.0) {
value = pow(10.0, exponent) * mant;
Modified: trunk/src/plfreetype.c
===================================================================
--- trunk/src/plfreetype.c 2009-02-08 22:26:44 UTC (rev 9476)
+++ trunk/src/plfreetype.c 2009-02-08 22:34:26 UTC (rev 9477)
@@ -648,7 +648,7 @@
}
else
{
- strncat(WINDIR_PATH,"\\fonts\\arial.ttf",PLPLOT_MAX_PATH);
+ strncat(WINDIR_PATH,"\\fonts\\arial.ttf",PLPLOT_MAX_PATH-1-strlen(WINDIR_PATH));
if (access(WINDIR_PATH, F_OK)==0)
{
b=strrchr(WINDIR_PATH,'\\');
@@ -707,12 +707,12 @@
else {
strncpy(FT->font_name[i],font_dir,PLPLOT_MAX_PATH-1);
- strncat(FT->font_name[i],a,PLPLOT_MAX_PATH-1);
+ strncat(FT->font_name[i],a,PLPLOT_MAX_PATH-1-strlen(FT->font_name[i]));
}
} else {
strncpy(FT->font_name[i],font_dir,PLPLOT_MAX_PATH-1);
- strncat(FT->font_name[i],(char *)TrueTypeLookup[i].pfont,PLPLOT_MAX_PATH-1);
+ strncat(FT->font_name[i],(char *)TrueTypeLookup[i].pfont,PLPLOT_MAX_PATH-1-strlen(FT->font_name[i]));
}
FT->font_name[i][PLPLOT_MAX_PATH-1] = '\0';
Modified: trunk/src/plmap.c
===================================================================
--- trunk/src/plmap.c 2009-02-08 22:26:44 UTC (rev 9476)
+++ trunk/src/plmap.c 2009-02-08 22:34:26 UTC (rev 9477)
@@ -103,9 +103,9 @@
/*
* read map outline
*/
- strncpy(filename,type,100);
- strncat(filename,MAP_FILE,100);
+ strncpy(filename,type,99);
filename[99] = '\0';
+ strncat(filename,MAP_FILE,99-strlen(filename));
if ((in = plLibOpenPdfstrm(filename)) == NULL)
return;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|