Skip to content

Commit

Permalink
Fix SbSystemGetProperty() on raspi
Browse files Browse the repository at this point in the history
Make sure that for kSbSystemPropertyPlatformName it doesn't touch the
buffer unless the buffer is large enough to hold the platform name.

Change-Id: Ic7b32b0c33dc71c55a9b48f7d615c824c908efc1
(cherry picked from commit e806d0fc8d0418c6bc70c9a90a27be7367e98f98)
  • Loading branch information
xiaomings authored and briantting committed Aug 27, 2018
1 parent b8dcb65 commit 7c90c94
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions starboard/raspi/shared/system_get_property.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
#include "starboard/system.h"

#include <sys/utsname.h>

#include <string>

#include "starboard/log.h"
#include "starboard/string.h"

Expand Down Expand Up @@ -60,19 +63,10 @@ bool SbSystemGetProperty(SbSystemPropertyId property_id,
if (uname(&name) == -1)
return false;

if (SbStringCopy(out_value, "Raspian ", value_length) >= value_length)
return false;

if (SbStringConcat(out_value, name.sysname, value_length) >= value_length)
return false;

if (SbStringConcat(out_value, " ", value_length) >= value_length)
return false;

if (SbStringConcat(out_value, name.machine, value_length) >= value_length)
return false;
std::string temp =
starboard::FormatString("Raspian %s %s", name.sysname, name.machine);

return true;
return CopyStringAndTestIfSuccess(out_value, value_length, temp.c_str());
}

default:
Expand Down

0 comments on commit 7c90c94

Please sign in to comment.