<p>Lijian Zhao has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/25377">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">arch/x86/smbios: Consider conner case of Part Number<br><br>In case of all DMI Type 17 could be all empty, the strip trailing<br>whitespace code will have a zero length Part Number entry, which will<br>cause exception when using (len - 1) where len is zero. Add extra code<br>to cover this corner case.<br><br>BUG=None<br>TEST=Boot up fine with moowth platform, without this patch system will<br>stuck at "Create SMBIOS type 17".<br><br>Change-Id: Id870c983584771dc1b60b1c99e95bbe7c0d25c4c<br>Signed-off-by: Lijian Zhao <lijian.zhao@intel.com><br>---<br>M src/arch/x86/smbios.c<br>1 file changed, 8 insertions(+), 4 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/coreboot refs/changes/77/25377/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/arch/x86/smbios.c b/src/arch/x86/smbios.c</span><br><span>index 7079374..c14c231 100644</span><br><span>--- a/src/arch/x86/smbios.c</span><br><span>+++ b/src/arch/x86/smbios.c</span><br><span>@@ -232,10 +232,14 @@</span><br><span>  len = strlen(trimmed_part_number);</span><br><span> </span><br><span>       invalid = 0; /* assume valid */</span><br><span style="color: hsl(0, 100%, 40%);">- for (i = 0; i < len - 1; i++) {</span><br><span style="color: hsl(0, 100%, 40%);">-              if (trimmed_part_number[i] < ' ') {</span><br><span style="color: hsl(0, 100%, 40%);">-                  invalid = 1;</span><br><span style="color: hsl(0, 100%, 40%);">-                    trimmed_part_number[i] = '*';</span><br><span style="color: hsl(120, 100%, 40%);">+ if (len == 0)</span><br><span style="color: hsl(120, 100%, 40%);">+         invalid = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+  else {</span><br><span style="color: hsl(120, 100%, 40%);">+                for (i = 0; i < len - 1; i++) {</span><br><span style="color: hsl(120, 100%, 40%);">+                    if (trimmed_part_number[i] < ' ') {</span><br><span style="color: hsl(120, 100%, 40%);">+                                invalid = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+                          trimmed_part_number[i] = '*';</span><br><span style="color: hsl(120, 100%, 40%);">+                 }</span><br><span>            }</span><br><span>    }</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://review.coreboot.org/25377">change 25377</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://review.coreboot.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://review.coreboot.org/25377"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: coreboot </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Id870c983584771dc1b60b1c99e95bbe7c0d25c4c </div>
<div style="display:none"> Gerrit-Change-Number: 25377 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Lijian Zhao <lijian.zhao@intel.com> </div>