buffer truncation looking up MIME types

Per subsequent discussions, switching to BString::SetToFormat which completely
eliminates the need for allocating a fixed buffer and will avoid truncation.

Change-Id: Ic2a803594877a0a6fb1bc4eba937268351e6f45c
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8837
Haiku-Format: Haiku-format Bot <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
Tested-by: Commit checker robot <[email protected]>
This commit is contained in:
Dave Slusher
2025-01-28 16:44:06 +00:00
committed by waddlesplash
parent 36fac427b5
commit 61d47c1e92
2 changed files with 4 additions and 6 deletions
+2 -3
View File
@@ -375,9 +375,8 @@ AssociatedTypes::BuildAssociatedTypesTable()
if (subEntry.GetName(subtype) == B_OK) {
BPrivate::Storage::to_lower(subtype);
char fulltype[B_PATH_NAME_LENGTH];
snprintf(fulltype, B_PATH_NAME_LENGTH, "%s/%s",
supertype, subtype);
BString fulltype;
fulltype.SetToFormat("%s/%s", supertype, subtype);
// Process the subtype
ProcessType(fulltype);
+2 -3
View File
@@ -373,9 +373,8 @@ SnifferRules::BuildRuleList()
if (subEntry.GetName(subtype) == B_OK) {
BPrivate::Storage::to_lower(subtype);
char fulltype[B_PATH_NAME_LENGTH];
snprintf(fulltype, B_PATH_NAME_LENGTH, "%s/%s",
supertype, subtype);
BString fulltype;
fulltype.SetToFormat("%s/%s", supertype, subtype);
// Process the subtype
ProcessType(fulltype, &bytesNeeded);