[haiku-commits] r40650 - haiku/trunk/src/kits/tracker

  • From: stpere@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 24 Feb 2011 02:23:21 +0100 (CET)

Author: stpere
Date: 2011-02-24 02:23:21 +0100 (Thu, 24 Feb 2011)
New Revision: 40650
Changeset: http://dev.haiku-os.org/changeset/40650

Modified:
   haiku/trunk/src/kits/tracker/FSUtils.cpp
   haiku/trunk/src/kits/tracker/FindPanel.cpp
Log:
Replace occurences of strcpy and strcat by strlcpy and strlcat. At both places, 
while improbable, it was possible to get string overflows.

CID 9043, 9044


Modified: haiku/trunk/src/kits/tracker/FSUtils.cpp
===================================================================
--- haiku/trunk/src/kits/tracker/FSUtils.cpp    2011-02-24 01:09:24 UTC (rev 
40649)
+++ haiku/trunk/src/kits/tracker/FSUtils.cpp    2011-02-24 01:23:21 UTC (rev 
40650)
@@ -2996,7 +2996,7 @@
        status_t result = dir.InitCheck();
        if (result == B_OK) {
                char name[B_FILE_NAME_LENGTH];
-               strcpy(name, B_TRANSLATE("New folder"));
+               strlcpy(name, B_TRANSLATE("New folder"), sizeof(name));
 
                int32 fnum = 1;
                while (dir.Contains(name)) {

Modified: haiku/trunk/src/kits/tracker/FindPanel.cpp
===================================================================
--- haiku/trunk/src/kits/tracker/FindPanel.cpp  2011-02-24 01:09:24 UTC (rev 
40649)
+++ haiku/trunk/src/kits/tracker/FindPanel.cpp  2011-02-24 01:23:21 UTC (rev 
40650)
@@ -1319,9 +1319,9 @@
        if (strcmp(kAllMimeTypes, type)) {
                // add an asterisk if we are searching for a supertype
                char buffer[B_FILE_NAME_LENGTH];
-               if (strchr(type,'/') == NULL) {
-                       strcpy(buffer,type);
-                       strcat(buffer,"/*");
+               if (strchr(type, '/') == NULL) {
+                       strlcpy(buffer, type, sizeof(buffer));
+                       strlcat(buffer, "/*", sizeof(buffer));
                        type = buffer;
                }
 


Other related posts:

  • » [haiku-commits] r40650 - haiku/trunk/src/kits/tracker - stpere