[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Minios-devel] [UNIKRAFT PATCH] lib/nolibc: Fix vsnprintf when size is zero
Hi Razvan,[adding Wei as a heads-up, as the code came from Minios, and this bug most likely appears there, too] after looking into this a bit more, making my own test case and debugging, I understand now what the problem is. This is triggered by line 376 in lib/nolibc/stdio.c, where PCHAR is called with a postdecrement. However, the PCHAR macro does not evaluate its input if there is nothing to write any more, so the postdecrement is never executed, leading to the infinite loop. The patch looks good, but could you write a bit more of a verbose commit message, so it's clear what was going on half a year from now? Basically that a macro should always evaluate its input variables exactly once, hence we need this temporary variable outside the if-clause, otherwise a postdecrement such as in line 376 might not happen if we're already outside the writable area of the output buffer and are only doing this to calculate the size we would've returned if there was enough space available, etc. etc. something like this. Thanks! Florian On 08/17/2018 04:35 PM, Florian Schmidt wrote: Hi Razvan, On 08/16/2018 04:43 PM, Razvan Rotaru wrote:Modified PCHAR macro so that it evaluates its parameter and updates their values every time. Without this, when size is zero, vsnprintf blocks in an infinite loop whenever the format string contains '%d'.I've had a look at your patch, but I'm not sure I exactly understand the issue, and how your patch solves it. Can you provide a test case to make this clearer?Thanks, Florian -- Dr. Florian Schmidt フローリアン・シュミット Research Scientist, Systems and Machine Learning Group NEC Laboratories Europe Kurfürsten-Anlage 36, D-69115 Heidelberg Tel. +49 (0)6221 4342-265 Fax: +49 (0)6221 4342-155 e-mail: florian.schmidt@xxxxxxxxx ============================================================ Registered at Amtsgericht Mannheim, Germany, HRB728558 _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |