Skip to content

Commit b501ae9

Browse files
authored
[crash-handler] change sprintf -> snprintf to prevent buffer overrun (#1571)
1 parent f378234 commit b501ae9

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

obs-studio-server/source/util-crashmanager.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,11 @@ std::string PrettyBytes(uint64_t bytes)
140140
s++;
141141
count /= 1024;
142142
}
143-
if (count - floor(count) == 0.0)
144-
sprintf(temp, "%d%s", (int)count, suffixes[s]);
145-
else
146-
sprintf(temp, "%.1f%s", count, suffixes[s]);
143+
if (count - floor(count) == 0.0) {
144+
snprintf(temp, sizeof(temp), "%d%s", static_cast<int>(count), suffixes[s]);
145+
} else {
146+
snprintf(temp, sizeof(temp), "%.1f%s", count, suffixes[s]);
147+
}
147148

148149
return std::string(temp);
149150
}

0 commit comments

Comments
 (0)