diff options
author | Michael R Sweet <michael.r.sweet@gmail.com> | 2019-04-20 09:13:32 -0400 |
---|---|---|
committer | Michael R Sweet <michael.r.sweet@gmail.com> | 2019-04-20 09:13:32 -0400 |
commit | 507c4adcc817c2d80643ecee2cb55dff305236f9 (patch) | |
tree | 0b4567e44b8a7af86fa75409858f76976bb82d80 /cgi-bin | |
parent | 60d8f88456d1240720cec82ff7375dff439da56e (diff) | |
download | cups-507c4adcc817c2d80643ecee2cb55dff305236f9.tar.gz |
More clang warning fixes.
Diffstat (limited to 'cgi-bin')
-rw-r--r-- | cgi-bin/cgi.h | 11 | ||||
-rw-r--r-- | cgi-bin/help-index.c | 11 | ||||
-rw-r--r-- | cgi-bin/var.c | 30 |
3 files changed, 37 insertions, 15 deletions
diff --git a/cgi-bin/cgi.h b/cgi-bin/cgi.h index c7e221b28..11acb224d 100644 --- a/cgi-bin/cgi.h +++ b/cgi-bin/cgi.h @@ -1,10 +1,11 @@ /* * CGI support library definitions for CUPS. * - * Copyright 2007-2010 by Apple Inc. - * Copyright 1997-2006 by Easy Software Products. + * Copyright © 2007-2019 by Apple Inc. + * Copyright © 1997-2006 by Easy Software Products. * - * Licensed under Apache License v2.0. See the file "LICENSE" for more information. + * Licensed under Apache License v2.0. See the file "LICENSE" for more + * information. */ #ifndef _CUPS_CGI_H_ @@ -66,14 +67,14 @@ extern void cgiEndMultipart(void); extern char *cgiFormEncode(char *dst, const char *src, size_t dstsize); extern void cgiFreeSearch(void *search); -extern const char *cgiGetArray(const char *name, int element); +extern char *cgiGetArray(const char *name, int element); extern void cgiGetAttributes(ipp_t *request, const char *tmpl); extern const char *cgiGetCookie(const char *name); extern const cgi_file_t *cgiGetFile(void); extern cups_array_t *cgiGetIPPObjects(ipp_t *response, void *search); extern int cgiGetSize(const char *name); extern char *cgiGetTemplateDir(void); -extern const char *cgiGetVariable(const char *name); +extern char *cgiGetVariable(const char *name); extern int cgiInitialize(void); extern int cgiIsPOST(void); extern void cgiMoveJobs(http_t *http, const char *dest, int job_id); diff --git a/cgi-bin/help-index.c b/cgi-bin/help-index.c index a49536d6a..ce97e47a4 100644 --- a/cgi-bin/help-index.c +++ b/cgi-bin/help-index.c @@ -1,10 +1,11 @@ /* * Online help index routines for CUPS. * - * Copyright 2007-2017 by Apple Inc. - * Copyright 1997-2007 by Easy Software Products. + * Copyright © 2007-2019 by Apple Inc. + * Copyright © 1997-2007 by Easy Software Products. * - * Licensed under Apache License v2.0. See the file "LICENSE" for more information. + * Licensed under Apache License v2.0. See the file "LICENSE" for more + * information. */ /* @@ -340,6 +341,8 @@ helpLoadIndex(const char *hifile, /* I - Index filename */ while (isspace(*ptr & 255)) ptr ++; } + else + section[0] = '\0'; if (*ptr != '\"') break; @@ -1188,7 +1191,7 @@ help_new_node(const char *filename, /* I - Filename */ n->filename = strdup(filename); n->anchor = anchor ? strdup(anchor) : NULL; - n->section = *section ? strdup(section) : NULL; + n->section = (section && *section) ? strdup(section) : NULL; n->text = strdup(text); n->mtime = mtime; n->offset = offset; diff --git a/cgi-bin/var.c b/cgi-bin/var.c index 21b3c5308..306375bd6 100644 --- a/cgi-bin/var.c +++ b/cgi-bin/var.c @@ -4,7 +4,8 @@ * Copyright © 2007-2019 by Apple Inc. * Copyright © 1997-2005 by Easy Software Products. * - * Licensed under Apache License v2.0. See the file "LICENSE" for more information. + * Licensed under Apache License v2.0. See the file "LICENSE" for more + * information. */ /* @@ -113,7 +114,12 @@ cgiCheckVariables(const char *names) /* I - Variables to look for */ return (0); if (*val == '\0') + { + free((void *)val); return (0); /* Can't be blank, either! */ + } + + free((void *)val); } return (1); @@ -151,7 +157,7 @@ cgiClearVariables(void) * 'cgiGetArray()' - Get an element from a form array. */ -const char * /* O - Element value or NULL */ +char * /* O - Element value or NULL */ cgiGetArray(const char *name, /* I - Name of array variable */ int element) /* I - Element number (0 to N) */ { @@ -214,7 +220,7 @@ cgiGetSize(const char *name) /* I - Name of variable */ * array of values, returns the last element. */ -const char * /* O - Value of variable */ +char * /* O - Value of variable */ cgiGetVariable(const char *name) /* I - Name of variable */ { const _cgi_var_t *var; /* Returned variable */ @@ -312,11 +318,18 @@ cgiInitialize(void) else fputs("DEBUG: " CUPS_SID " form variable is not present.\n", stderr); + free((void *)cups_sid_form); + cgiClearVariables(); + return (0); } else + { + free((void *)cups_sid_form); + return (1); + } } else return (0); @@ -868,12 +881,13 @@ cgi_initialize_multipart( if (line[0]) cgiSetArray(name, atoi(ptr) - 1, line); } - else if (cgiGetVariable(name)) + else if ((ptr = cgiGetVariable(name)) != NULL) { /* * Add another element in the array... */ + free(ptr); cgiSetArray(name, cgiGetSize(name), line); } else @@ -1028,7 +1042,8 @@ cgi_initialize_string(const char *data) /* I - Form data string */ char *s, /* Pointer to current form string */ ch, /* Temporary character */ name[255], /* Name of form variable */ - value[65536]; /* Variable value */ + value[65536], /* Variable value */ + *temp; /* Temporary pointer */ /* @@ -1130,8 +1145,11 @@ cgi_initialize_string(const char *data) /* I - Form data string */ if (value[0]) cgiSetArray(name, atoi(s) - 1, value); } - else if (cgiGetVariable(name) != NULL) + else if ((temp = cgiGetVariable(name)) != NULL) + { + free(temp); cgiSetArray(name, cgiGetSize(name), value); + } else cgiSetVariable(name, value); } |