Skip to content

Loopity loop #736

@alejandro-colomar

Description

@alejandro-colomar

I was joking the other day that I would like to see someone write a continue; within a do {...} while (0);, just for fun. I'd be 50/50 between burning the computer of the offender and ROFL. Example:

#define loopity_loop()  do { for (;;) { break; } continue; } while (0-0)

Well, unless I'm missing something, as often, reality surpasses my dreams. Look at what I just found:

		for (token = strtok_r(p, " \n\t", &saveptr);
		     token;
		     token = strtok_r(NULL, " \n\t", &saveptr)) {
			char libname[65];
			void *h;
			if (strcmp(token, "files") == 0) {
				subid_nss = NULL;
				goto done;
			}
			if (strlen(token) > 50) {
				fprintf(shadow_logfd, "Subid NSS module name too long (longer than 50 characters): %s\n", token);
				fprintf(shadow_logfd, "Using files\n");
				subid_nss = NULL;
				goto done;
			}
			snprintf(libname, 64,  "libsubid_%s.so", token);
			h = dlopen(libname, RTLD_LAZY);
			if (!h) {
				fprintf(shadow_logfd, "Error opening %s: %s\n", libname, dlerror());
				fprintf(shadow_logfd, "Using files\n");
				subid_nss = NULL;
				goto done;
			}
			subid_nss = MALLOC(1, struct subid_nss_ops);
			if (!subid_nss) {
				dlclose(h);
				goto done;
			}
			subid_nss->has_range = dlsym(h, "shadow_subid_has_range");
			if (!subid_nss->has_range) {
				fprintf(shadow_logfd, "%s did not provide @has_range@\n", libname);
				dlclose(h);
				free(subid_nss);
				subid_nss = NULL;
				goto done;
			}
			subid_nss->list_owner_ranges = dlsym(h, "shadow_subid_list_owner_ranges");
			if (!subid_nss->list_owner_ranges) {
				fprintf(shadow_logfd, "%s did not provide @list_owner_ranges@\n", libname);
				dlclose(h);
				free(subid_nss);
				subid_nss = NULL;
				goto done;
			}
			subid_nss->find_subid_owners = dlsym(h, "shadow_subid_find_subid_owners");
			if (!subid_nss->find_subid_owners) {
				fprintf(shadow_logfd, "%s did not provide @find_subid_owners@\n", libname);
				dlclose(h);
				free(subid_nss);
				subid_nss = NULL;
				goto done;
			}
			subid_nss->handle = h;
			goto done;
		}

If that's a loop, I'm Bugs Bunny. The done label is of course after the (shall I really call it loop?) loop.

I'll prepare a PR...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions