MCPcopy Create free account
hub / github.com/F-Stack/f-stack / db_script_valid

Function db_script_valid

freebsd/ddb/db_script.c:163–181  ·  view source on GitHub ↗

* Perform very rudimentary validation of a proposed script. It would be * easy to imagine something more comprehensive. The script string is * validated in a static buffer. */

Source from the content-addressed store, hash-verified

161 * validated in a static buffer.
162 */
163static int
164db_script_valid(const char *scriptname, const char *script)
165{
166 char *buffer, *command;
167
168 if (strlen(scriptname) == 0)
169 return (EINVAL);
170 if (strlen(scriptname) >= DB_MAXSCRIPTNAME)
171 return (EINVAL);
172 if (strlen(script) >= DB_MAXSCRIPTLEN)
173 return (EINVAL);
174 buffer = db_static_buffer;
175 strcpy(buffer, script);
176 while ((command = strsep(&buffer, ";")) != NULL) {
177 if (strlen(command) >= DB_MAXLINE)
178 return (EINVAL);
179 }
180 return (0);
181}
182
183/*
184 * Modify an existing script or add a new script with the specified script

Callers 1

db_script_setFunction · 0.85

Calls 1

strsepFunction · 0.85

Tested by

no test coverage detected