[haiku-commits] r40716 - haiku/trunk/src/apps/aboutsystem

  • From: jonas@xxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 27 Feb 2011 07:16:31 +0100 (CET)

Author: kirilla
Date: 2011-02-27 07:16:30 +0100 (Sun, 27 Feb 2011)
New Revision: 40716
Changeset: http://dev.haiku-os.org/changeset/40716

Modified:
   haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp
Log:
CID 8952 STRING_OVERFLOW
CID 6753 SECURE_CODING
CID 3299 MISSING_BREAK

Modified: haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp
===================================================================
--- haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp    2011-02-27 03:08:27 UTC 
(rev 40715)
+++ haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp    2011-02-27 06:16:30 UTC 
(rev 40716)
@@ -519,7 +519,7 @@
        // OS Version
 
        char string[1024];
-       strcpy(string, B_TRANSLATE("Unknown"));
+       strlcpy(string, B_TRANSLATE("Unknown"), sizeof(string));
 
        // the version is stored in the BEOS:APP_VERSION attribute of libbe.so
        BPath path;
@@ -534,7 +534,7 @@
                        && appFileInfo.GetVersionInfo(&versionInfo,
                                B_APP_VERSION_KIND) == B_OK
                        && versionInfo.short_info[0] != '\0')
-                       strcpy(string, versionInfo.short_info);
+                       strlcpy(string, versionInfo.short_info, sizeof(string));
        }
 
        // Add revision from uname() info
@@ -597,9 +597,9 @@
 
        int32 clockSpeed = get_rounded_cpu_speed();
        if (clockSpeed < 1000)
-               sprintf(string, B_TRANSLATE("%ld MHz"), clockSpeed);
+               snprintf(string, sizeof(string), B_TRANSLATE("%ld MHz"), 
clockSpeed);
        else
-               sprintf(string, B_TRANSLATE("%.2f GHz"), clockSpeed / 1000.0f);
+               snprintf(string, sizeof(string), B_TRANSLATE("%.2f GHz"), 
clockSpeed / 1000.0f);
 
        BStringView* frequencyView = new BStringView("frequencytext", string);
        frequencyView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
@@ -740,6 +740,7 @@
                {
                        printf("Easter egg\n");
                        PickRandomHaiku();
+                       break;
                }
 
                default:


Other related posts:

  • » [haiku-commits] r40716 - haiku/trunk/src/apps/aboutsystem - jonas