Skip to content
This repository
Browse code

[rbp] Avoid overflow in version string

gedit complains about invalid characters when opening xbmc.log file produced by pi
Since the change from perforce revision number to git hash, the version string has increased in size.

Fortunately we don't overrun the "response" buffer.
Unfortunately when buffer doesn't fit, it is not null terminated, so logging message pulls in garbage.

Version string looks like:
Jun 17 2013 20:49:11
Copyright (c) 2012 Broadcom
version d380dde (clean) (release)

So, 80 characters is not enough (it is about 115 plus newlines).
160 seems more than enough, but truncate the string just in case.
  • Loading branch information...
commit 7abe83620ce75bf4d7e12e0bc6f6f7425fb04ae7 1 parent 0faa3d2
popcornmix authored June 17, 2013

Showing 1 changed file with 3 additions and 2 deletions. Show diff stats Hide diff stats

  1. 5  xbmc/linux/RBP.cpp
5  xbmc/linux/RBP.cpp
@@ -55,9 +55,10 @@ bool CRBP::Initialize()
55 55
 
56 56
 void CRBP::LogFirmwareVerison()
57 57
 {
58  
-  char  response[80];
  58
+  char  response[160];
59 59
   m_DllBcmHost->vc_gencmd(response, sizeof response, "version");
60  
-  CLog::Log(LOGNOTICE, "Raspberry PI firmware version: %s\n", response);
  60
+  response[sizeof(response) - 1] = '\0';
  61
+  CLog::Log(LOGNOTICE, "Raspberry PI firmware version: %s", response);
61 62
 }
62 63
 
63 64
 void CRBP::Deinitialize()

0 notes on commit 7abe836

Please sign in to comment.
Something went wrong with that request. Please try again.