r23779: Change from v2 or later to v3 or later.
[gd/samba/.git] / source3 / rpc_parse / parse_spoolss.c
index 4cd410d728d511fc3fc23852a4d2ba169c4311df..a2291e020b80a9eb87667487f0f4e9a3eb2d084d 100644 (file)
@@ -9,7 +9,7 @@
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
+ *  the Free Software Foundation; either version 3 of the License, or
  *  (at your option) any later version.
  *  
  *  This program is distributed in the hope that it will be useful,
@@ -7022,10 +7022,10 @@ static BOOL spoolss_io_printer_enum_values_ctr(const char *desc, prs_struct *ps,
                data_offset,
                current_offset;
        const uint32 basic_unit = 20; /* size of static portion of enum_values */
-       
+
        prs_debug(ps, depth, desc, "spoolss_io_printer_enum_values_ctr");
        depth++;        
-       
+
        /* 
         * offset data begins at 20 bytes per structure * size_of_array.
         * Don't forget the uint32 at the beginning 
@@ -7042,10 +7042,29 @@ static BOOL spoolss_io_printer_enum_values_ctr(const char *desc, prs_struct *ps,
        }
 
        for (i=0; i<ctr->size_of_array; i++) {
+               uint32 base_offset, return_offset;
+
+               base_offset = prs_offset(ps);
+
                valuename_offset = current_offset;
                if (!prs_uint32("valuename_offset", ps, depth, &valuename_offset))
                        return False;
 
+               /* Read or write the value. */
+
+               return_offset = prs_offset(ps);
+
+               if (!prs_set_offset(ps, base_offset + valuename_offset)) {
+                       return False;
+               }
+
+               if (!prs_unistr("valuename", ps, depth, &ctr->values[i].valuename))
+                       return False;
+
+               /* And go back. */
+               if (!prs_set_offset(ps, return_offset))
+                       return False;
+
                if (!prs_uint32("value_len", ps, depth, &ctr->values[i].value_len))
                        return False;
        
@@ -7060,21 +7079,14 @@ static BOOL spoolss_io_printer_enum_values_ctr(const char *desc, prs_struct *ps,
                if (!prs_uint32("data_len", ps, depth, &ctr->values[i].data_len))
                        return False;
                        
-               current_offset  = data_offset + ctr->values[i].data_len - basic_unit;
-               /* account for 2 byte alignment */
-               current_offset += (current_offset % 2);
-       }
+               /* Read or write the data. */
 
-       /* 
-        * loop #2 for writing the dynamically size objects; pay 
-        * attention to 2-byte alignment here....
-        */
-       
-       for (i=0; i<ctr->size_of_array; i++) {
-       
-               if (!prs_unistr("valuename", ps, depth, &ctr->values[i].valuename))
+               return_offset = prs_offset(ps);
+
+               if (!prs_set_offset(ps, base_offset + data_offset)) {
                        return False;
-               
+               }
+
                if ( ctr->values[i].data_len ) {
                        if ( UNMARSHALLING(ps) ) {
                                ctr->values[i].data = PRS_ALLOC_MEM(ps, uint8, ctr->values[i].data_len);
@@ -7084,11 +7096,30 @@ static BOOL spoolss_io_printer_enum_values_ctr(const char *desc, prs_struct *ps,
                        if (!prs_uint8s(False, "data", ps, depth, ctr->values[i].data, ctr->values[i].data_len))
                                return False;
                }
-                       
-               if ( !prs_align_uint16(ps) )
+
+               current_offset  = data_offset + ctr->values[i].data_len - basic_unit;
+               /* account for 2 byte alignment */
+               current_offset += (current_offset % 2);
+
+               /* Remember how far we got. */
+               data_offset = prs_offset(ps);
+
+               /* And go back. */
+               if (!prs_set_offset(ps, return_offset))
                        return False;
+
        }
 
+       /* Go to the last data offset we got to. */
+
+       if (!prs_set_offset(ps, data_offset))
+               return False;
+
+       /* And ensure we're 2 byte aligned. */
+
+       if ( !prs_align_uint16(ps) )
+               return False;
+
        return True;    
 }