[syslinux] [PATCH] pxe: fix OACK packet handling

Sebastian Herbszt herbszt at gmx.de
Sat Aug 8 15:53:07 PDT 2009


Sebastian Herbszt wrote:
> liu Aleaxander wrote:
>> So, here is the new patch:
>> 
>>>>From f7e36b4de4387f8662dbb88b550915a021e8f99b Mon Sep 17 00:00:00 2001
>> From: Liu Aleaxander <Aleaxander at gmail.com>
>> Date: Sat, 8 Aug 2009 16:05:08 +0800
>> Subject: [PATCH] core:PXELINUX: fix the OACK option parsing bug.
>> 
>> the current code can just handle one option beacuse I put the do-while loop
>> in the wrong position.
>> 
>> Signed-off-by: Liu Aleaxander <Aleaxander at gmail.com>
>> ---
>> core/pxe.c |   26 +++++++++++++-------------
>> 1 files changed, 13 insertions(+), 13 deletions(-)
>> 
>> diff --git a/core/pxe.c b/core/pxe.c
>> index 81d3e23..bda1a54 100644
>> --- a/core/pxe.c
>> +++ b/core/pxe.c
>> @@ -928,20 +928,20 @@ static void pxe_searchdir(char *filename, struct file
>> *file)
>>         if (*options == 0)
>>             goto done;
>> 
>> -        dst = src = options;
>> -        while (buffersize--) {
>> -            if (*src == 0)
>> -                break;          /* found a final null */
>> -            *dst++ = *src++ | 0x20;
>> -            if (!buffersize)
>> -                goto done;  /* found no final null */
>> -        }
>> -
>> -        /*
>> -         * Parse option pointed to by options; guaranteed to be
>> null-terminated
>> -         */
>> -        p = options;
>>         do {
>> +            dst = src = options;
>> +            while (buffersize--) {
>> +                if (*src == 0)
>> +                    break;          /* found a final null */
>> +                *dst++ = *src++ | 0x20;
>> +                if (!buffersize)
>> +                    goto done;  /* found no final null */
>> +            }
>> +
>> +            /*
>> +             * Parse option pointed to by options; guaranteed to be
>> null-terminated
>> +             */
>> +            p = options;
>>             tftp_opt = tftp_options;
>>             for (i = 0; i < tftp_opts; i++) {
>>                 if (!strncmp(p, tftp_opt->str_ptr,tftp_opt->str_len))
> 
> I tried this one and it doesn't seem to fix the issue. "options" is not advanced so in my case
> the "tsize" option is checked twice (?) instead of checking "blksize" on the second iteration.

This patch fixes the outstanding issues.

- Sebastian

diff --git a/core/pxe.c b/core/pxe.c
index 12c3113..7cf5cc1 100644
--- a/core/pxe.c
+++ b/core/pxe.c
@@ -933,8 +933,10 @@ static void pxe_searchdir(char *filename, struct file *file)
          * Now we need to parse the OACK packet to get the transfer
          * and packet sizes.
          */
-        if (!buffersize)
+        if (!buffersize) {
+            filesize = -1;
             goto done;       /* No options acked */
+        }

         /*
          * If we find an option which starts with a NUL byte,
@@ -964,8 +966,10 @@ static void pxe_searchdir(char *filename, struct file *file)
             p = options;
             tftp_opt = tftp_options;
             for (i = 0; i < tftp_opts; i++) {
-                if (!strncmp(p, tftp_opt->str_ptr,tftp_opt->str_len))
+                if (!strncmp(p, tftp_opt->str_ptr,tftp_opt->str_len)) {
+                    options += tftp_opt->str_len;
                     break;
+                }
                 tftp_opt++;
             }
             if (i == tftp_opts)
@@ -974,11 +978,12 @@ static void pxe_searchdir(char *filename, struct file *file)
             p += tftp_opt->str_len;

             /* get the address of the filed that we want to write on */
-            data_ptr = (uint32_t *)((char *)file + tftp_opt->offset);
+            data_ptr = (uint32_t *)((char *)open_file + tftp_opt->offset);
             *data_ptr = 0;

             /* do convert a number-string to decimal number, just like atoi */
             while (buffersize--) {
+                options++;
                 if (*p == 0)
                     break;              /* found a final null */
                 if (*p > '9')




More information about the Syslinux mailing list