< prev index next >

src/java.desktop/unix/native/common/awt/fontpath.c

Print this page
rev 16167 : 8170525: Fix minor issues in awt coding

@@ -241,12 +241,13 @@
             tempFontPath++;
         }
 
         appendDirList[index] = 0;
         if ( doNotAppend == 0 ) {
-            strcpy ( fontDirPath, fDirP->name[index] );
-            strcat ( fontDirPath, "/fonts.dir" );
+            strncpy(fontDirPath, fDirP->name[index], sizeof(fontDirPath));
+            fontDirPath[sizeof(fontDirPath)-1] = '\0';
+            strncat(fontDirPath, "/fonts.dir", sizeof(fontDirPath) - strlen(fontDirPath));
             dirFile = open ( fontDirPath, O_RDONLY, 0 );
             if ( dirFile == -1 ) {
                 doNotAppend = 1;
             } else {
                close ( dirFile );
< prev index next >