samba-cvs.cvs
[Top] [All Lists]

svn commit: samba r26344 - in branches/SAMBA_4_0: . source/param source/

Subject: svn commit: samba r26344 - in branches/SAMBA_4_0: . source/param source/utils
From:
Date: Sat, 8 Dec 2007 23:32:03 +0000 GMT
Author: jelmer
Date: 2007-12-08 23:32:01 +0000 (Sat, 08 Dec 2007)
New Revision: 26344

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=26344

Log:
Fix memory access.
Modified:
   branches/SAMBA_4_0/
   branches/SAMBA_4_0/source/param/loadparm.c
   branches/SAMBA_4_0/source/utils/testparm.c


Changeset:

Property changes on: branches/SAMBA_4_0
___________________________________________________________________
Name: bzr:revision-info
...skipped...
Name: bzr:revision-id:v3-trunk0
...skipped...

Modified: branches/SAMBA_4_0/source/param/loadparm.c
===================================================================
--- branches/SAMBA_4_0/source/param/loadparm.c  2007-12-08 23:31:58 UTC (rev 
26343)
+++ branches/SAMBA_4_0/source/param/loadparm.c  2007-12-08 23:32:01 UTC (rev 
26344)
@@ -259,7 +259,7 @@
 /* local variables */
 struct loadparm_context {
        struct loadparm_global *globals;
-       struct loadparm_service **ServicePtrs;
+       struct loadparm_service **services;
        int iNumServices;
        struct loadparm_service *currentService;
        bool bInGlobalSection;
@@ -1067,37 +1067,35 @@
 
        /* find an invalid one */
        for (i = 0; i < lp_ctx->iNumServices; i++)
-               if (lp_ctx->ServicePtrs[i] == NULL)
+               if (lp_ctx->services[i] == NULL)
                        break;
 
        /* if not, then create one */
        if (i == lp_ctx->iNumServices) {
                struct loadparm_service **tsp;
                
-               tsp = talloc_realloc(lp_ctx, lp_ctx->ServicePtrs, struct 
loadparm_service *, 
-                               num_to_alloc);
+               tsp = talloc_realloc(lp_ctx, lp_ctx->services, struct 
loadparm_service *, num_to_alloc);
                                           
                if (!tsp) {
-                       DEBUG(0,("lp_add_service: failed to enlarge 
ServicePtrs!\n"));
+                       DEBUG(0,("lp_add_service: failed to enlarge 
services!\n"));
                        return NULL;
+               } else {
+                       lp_ctx->services = tsp;
+                       lp_ctx->services[lp_ctx->iNumServices] = NULL;
                }
-               else {
-                       lp_ctx->ServicePtrs = tsp;
-                       lp_ctx->ServicePtrs[lp_ctx->iNumServices] = NULL;
-               }
 
                lp_ctx->iNumServices++;
        } 
 
-       lp_ctx->ServicePtrs[i] = init_service(lp_ctx);
-       if (lp_ctx->ServicePtrs[i] == NULL) {
+       lp_ctx->services[i] = init_service(lp_ctx->services);
+       if (lp_ctx->services[i] == NULL) {
                DEBUG(0,("lp_add_service: out of memory!\n"));
                return NULL;
        }
-       copy_service(lp_ctx->ServicePtrs[i], &tservice, NULL);
+       copy_service(lp_ctx->services[i], &tservice, NULL);
        if (name != NULL)
-               string_set(lp_ctx->ServicePtrs[i], 
&lp_ctx->ServicePtrs[i]->szService, name);
-       return lp_ctx->ServicePtrs[i];
+               string_set(lp_ctx->services[i], 
&lp_ctx->services[i]->szService, name);
+       return lp_ctx->services[i];
 }
 
 /***************************************************************************
@@ -1192,7 +1190,7 @@
        /* the printer name is set to the service name. */
        string_set(service, &service->szPrintername, pszPrintername);
        string_set(service, &service->comment, comment);
-       service->bBrowseable = sDefault.bBrowseable;
+       service->bBrowseable = default_service->bBrowseable;
        /* Printers cannot be read_only. */
        service->bRead_only = false;
        /* Printer services must be printable. */
@@ -1266,9 +1264,9 @@
        int iService;
 
        for (iService = lp_ctx->iNumServices - 1; iService >= 0; iService--)
-               if (lp_ctx->ServicePtrs[iService] != NULL &&
-                   strwicmp(lp_ctx->ServicePtrs[iService]->szService, 
pszServiceName) == 0) {
-                       return lp_ctx->ServicePtrs[iService];
+               if (lp_ctx->services[iService] != NULL &&
+                   strwicmp(lp_ctx->services[iService]->szService, 
pszServiceName) == 0) {
+                       return lp_ctx->services[iService];
                }
 
        return NULL;
@@ -2079,7 +2077,8 @@
 Display the contents of the global structure.
 ***************************************************************************/
 
-static void dump_globals(struct loadparm_context *lp_ctx, FILE *f, bool 
show_defaults)
+static void dump_globals(struct loadparm_context *lp_ctx, FILE *f, 
+                        bool show_defaults)
 {
        int i;
        struct param_opt *data;
@@ -2146,10 +2145,10 @@
         }
 }
 
-bool lp_dump_a_parameter(struct loadparm_context *lp_ctx, int snum, const char 
*parm_name, FILE * f, 
-                        bool isGlobal)
+bool lp_dump_a_parameter(struct loadparm_context *lp_ctx, 
+                        struct loadparm_service *service, 
+                        const char *parm_name, FILE * f, bool isGlobal)
 {
-       struct loadparm_service * pService = lp_ctx->ServicePtrs[snum];
        struct parm_struct *parm;
        void *ptr;
        
@@ -2161,7 +2160,7 @@
        if (isGlobal)
                ptr = ((char *)&sDefault) + parm->offset;
        else
-               ptr = ((char *)pService) + parm->offset;
+               ptr = ((char *)service) + parm->offset;
        
        print_parameter(parm, ptr, f);
        fprintf(f, "\n");
@@ -2191,7 +2190,7 @@
                        return &parm_table[(*i)++];
                }
        } else {
-               struct loadparm_service *pService = lp_ctx->ServicePtrs[snum];
+               struct loadparm_service *pService = lp_ctx->services[snum];
 
                for (; parm_table[*i].label; (*i)++) {
                        if (parm_table[*i].class == P_LOCAL &&
@@ -2247,12 +2246,12 @@
 {
        int i;
        for (i = 0; i < lp_ctx->iNumServices; i++) {
-               if (lp_ctx->ServicePtrs[i] == NULL)
+               if (lp_ctx->services[i] == NULL)
                        continue;
 
                if (!snumused || !snumused(smb, i)) {
-                       talloc_free(lp_ctx->ServicePtrs[i]);
-                       lp_ctx->ServicePtrs[i] = NULL;
+                       talloc_free(lp_ctx->services[i]);
+                       lp_ctx->services[i] = NULL;
                }
        }
 }
@@ -2527,7 +2526,7 @@
        dump_a_service(&sDefault, f);
 
        for (iService = 0; iService < maxtoprint; iService++)
-               lp_dump_one(f, show_defaults, lp_ctx->ServicePtrs[iService]);
+               lp_dump_one(f, show_defaults, lp_ctx->services[iService]);
 }
 
 /***************************************************************************
@@ -2546,7 +2545,7 @@
 struct loadparm_service *lp_servicebynum(struct loadparm_context *lp_ctx,
                                         int snum)
 {
-       return lp_ctx->ServicePtrs[snum];
+       return lp_ctx->services[snum];
 }
 
 struct loadparm_service *lp_service(struct loadparm_context *lp_ctx, 
@@ -2556,17 +2555,17 @@
         char *serviceName;
  
        for (iService = lp_ctx->iNumServices - 1; iService >= 0; iService--) {
-               if (lp_ctx->ServicePtrs[iService] && 
-                   lp_ctx->ServicePtrs[iService]->szService) {
+               if (lp_ctx->services[iService] && 
+                   lp_ctx->services[iService]->szService) {
                        /*
                         * The substitution here is used to support %U is
                         * service names
                         */
                        serviceName = standard_sub_basic(
-                                       lp_ctx->ServicePtrs[iService],
-                                       
lp_ctx->ServicePtrs[iService]->szService);
+                                       lp_ctx->services[iService],
+                                       lp_ctx->services[iService]->szService);
                        if (strequal(serviceName, service_name))
-                               return lp_ctx->ServicePtrs[iService];
+                               return lp_ctx->services[iService];
                }
        }
 

Modified: branches/SAMBA_4_0/source/utils/testparm.c
===================================================================
--- branches/SAMBA_4_0/source/utils/testparm.c  2007-12-08 23:31:58 UTC (rev 
26343)
+++ branches/SAMBA_4_0/source/utils/testparm.c  2007-12-08 23:32:01 UTC (rev 
26344)
@@ -127,7 +127,7 @@
                        fflush(stdout);
                        getc(stdin);
                }
-               if (section_name || parameter_name) {
+               if (section_name != NULL || parameter_name != NULL) {
                        struct loadparm_service *service = NULL;
                        if (!section_name) {
                                section_name = GLOBAL_NAME;
@@ -141,7 +141,7 @@
                        if (!parameter_name) {
                                lp_dump_one(stdout, show_defaults, service);
                        } else {
-                               ret = !lp_dump_a_parameter(lp_ctx, s, 
parameter_name, stdout, (service == NULL));
+                               ret = !lp_dump_a_parameter(lp_ctx, service, 
parameter_name, stdout, (service == NULL));
                        }
                } else {
                        lp_dump(lp_ctx, stdout, show_defaults, 
lp_numservices(lp_ctx));

<Prev in Thread] Current Thread [Next in Thread>
  • svn commit: samba r26344 - in branches/SAMBA_4_0: . source/param source/utils, jelmer <=