CID 8952 STRING_OVERFLOW

CID 6753 SECURE_CODING
CID 3299 MISSING_BREAK

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40716 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jonas Sundström
2011-02-27 06:16:30 +00:00
parent 19b0b28182
commit 10444a4364
+5 -4
View File
@@ -519,7 +519,7 @@ AboutView::AboutView()
// OS Version // OS Version
char string[1024]; 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 // the version is stored in the BEOS:APP_VERSION attribute of libbe.so
BPath path; BPath path;
@@ -534,7 +534,7 @@ AboutView::AboutView()
&& appFileInfo.GetVersionInfo(&versionInfo, && appFileInfo.GetVersionInfo(&versionInfo,
B_APP_VERSION_KIND) == B_OK B_APP_VERSION_KIND) == B_OK
&& versionInfo.short_info[0] != '\0') && versionInfo.short_info[0] != '\0')
strcpy(string, versionInfo.short_info); strlcpy(string, versionInfo.short_info, sizeof(string));
} }
// Add revision from uname() info // Add revision from uname() info
@@ -597,9 +597,9 @@ AboutView::AboutView()
int32 clockSpeed = get_rounded_cpu_speed(); int32 clockSpeed = get_rounded_cpu_speed();
if (clockSpeed < 1000) if (clockSpeed < 1000)
sprintf(string, B_TRANSLATE("%ld MHz"), clockSpeed); snprintf(string, sizeof(string), B_TRANSLATE("%ld MHz"), clockSpeed);
else 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); BStringView* frequencyView = new BStringView("frequencytext", string);
frequencyView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, frequencyView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
@@ -740,6 +740,7 @@ AboutView::MessageReceived(BMessage* msg)
{ {
printf("Easter egg\n"); printf("Easter egg\n");
PickRandomHaiku(); PickRandomHaiku();
break;
} }
default: default: