[sudo-workers] wierd construction

Radovan Sroka rsroka at redhat.com
Tue Aug 18 05:58:37 MDT 2015


I'm just doing static analysis, and I found something curious in plugins/sudoers/visudo.c.

if (editor_path == NULL) {
	/* def_editor could be a path, split it up, avoiding strtok() */
	const char *def_editor_end = def_editor + strlen(def_editor);
	const char *cp, *ep;
	for (cp = sudo_strsplit(def_editor, def_editor_end, ":", &ep);
	    cp != NULL; cp = sudo_strsplit(NULL, def_editor_end, ":", &ep)) {
	    editor_path = resolve_editor(cp, (size_t)(ep - cp), 2, files,
		editor_argc, editor_argv, whitelist);
	    if (editor_path == NULL && errno != ENOENT)
	} while (ep != NULL && editor_path == NULL);

Do you see for-while construction?

I doubt that was your intention. I suppose that you were changing "for" for "while" cycle and not successful.

What do you thing about that?

Radovan Sroka

More information about the sudo-workers mailing list