[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Minios-devel] [UNIKRAFT PATCH v3 2/2] lib/ukargparse: Add maxlen handling to left_shift



Reviewed-by: Felipe Huici <felipe.huici@xxxxxxxxx>

On 01.07.19, 10:10, "Minios-devel on behalf of andrei.gogonea09@xxxxxxxxx" 
<minios-devel-bounces@xxxxxxxxxxxxxxxxxxxx on behalf of 
andrei.gogonea09@xxxxxxxxx> wrote:

    From: Andrei Gogonea <andrei.gogonea09@xxxxxxxxx>
    
    Change the signature of the left_shift function from argparse.c and add 
maxlen handling.
    
    Signed-off-by: Andrei Gogonea <andrei.gogonea09@xxxxxxxxx>
    ---
     lib/ukargparse/argparse.c | 17 ++++++++---------
     1 file changed, 8 insertions(+), 9 deletions(-)
    
    diff --git a/lib/ukargparse/argparse.c b/lib/ukargparse/argparse.c
    index b9e28f18..db7ed130 100644
    --- a/lib/ukargparse/argparse.c
    +++ b/lib/ukargparse/argparse.c
    @@ -37,11 +37,11 @@
     #include <uk/assert.h>
     
     
    -static void left_shift(char *buf) 
    +static void left_shift(char *buf, __sz index, __sz maxlen) 
     {
    -   while(*buf != '\0') {
    -           *buf = *(buf + 1);
    -           buf++;
    +   while(buf[index] != '\0' && index < maxlen) {
    +           buf[index] = buf[index + 1];
    +           index++;
        }
     }
     
    @@ -79,17 +79,16 @@ int uk_argnparse(char *argb, __sz maxlen, char *argv[], 
int maxcount)
                case '"':
                        if (!in_quote) {
                                in_quote = argb[i];
    -                           left_shift(&argb[i--]);
    +                           left_shift(argb, i, maxlen);
    +                           --i;
                                break;
                        }
                        if (in_quote == argb[i]) {
                                in_quote = '\0';
    -                           left_shift(&argb[i--]);
    +                           left_shift(argb, i, maxlen);
    +                           --i;
                                break;
                        }
    -                           
    -                   
    -
                        
                        /* Fall through */
                default:
    -- 
    2.11.0
    
    
    _______________________________________________
    Minios-devel mailing list
    Minios-devel@xxxxxxxxxxxxxxxxxxxx
    https://lists.xenproject.org/mailman/listinfo/minios-devel

_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.