Carl Shapiro pushed to branch master at cmucl / cmucl
Commits:
-
06958230
by Carl Shapiro at 2024-04-25T12:45:59-07:00
-
520213dd
by Carl Shapiro at 2024-04-26T02:00:30+00:00
1 changed file:
Changes:
... | ... | @@ -753,26 +753,27 @@ os_file_author(const char *path) |
753 | 753 | * Keep trying with larger buffers until a maximum is reached. We
|
754 | 754 | * assume (1 << 20) is large enough for any OS.
|
755 | 755 | */
|
756 | - while (size <= (1 << 20)) {
|
|
757 | - switch (getpwuid_r(sb.st_uid, &pwd, buffer, size, &ppwd)) {
|
|
758 | - case 0:
|
|
759 | - /* Success, though we might not have a matching entry */
|
|
760 | - result = (ppwd == NULL) ? NULL : strdup(pwd.pw_name);
|
|
761 | - goto exit;
|
|
762 | - case ERANGE:
|
|
763 | - /* Buffer is too small, double its size and try again */
|
|
764 | - size *= 2;
|
|
765 | - if ((buffer = realloc(obuffer, size)) == NULL) {
|
|
766 | - goto exit;
|
|
767 | - }
|
|
768 | - obuffer = buffer;
|
|
769 | - continue;
|
|
770 | - default:
|
|
771 | - /* All other errors */
|
|
772 | - goto exit;
|
|
773 | - }
|
|
756 | +again:
|
|
757 | + switch (getpwuid_r(sb.st_uid, &pwd, buffer, size, &ppwd)) {
|
|
758 | + case 0:
|
|
759 | + /* Success, though we might not have a matching entry */
|
|
760 | + result = (ppwd == NULL) ? NULL : strdup(pwd.pw_name);
|
|
761 | + break;
|
|
762 | + case ERANGE:
|
|
763 | + /* Buffer is too small, double its size and try again */
|
|
764 | + size *= 2;
|
|
765 | + if (size > (1 << 20)) {
|
|
766 | + break;
|
|
767 | + }
|
|
768 | + if ((buffer = realloc(obuffer, size)) == NULL) {
|
|
769 | + break;
|
|
770 | + }
|
|
771 | + obuffer = buffer;
|
|
772 | + goto again;
|
|
773 | + default:
|
|
774 | + /* All other errors */
|
|
775 | + break;
|
|
774 | 776 | }
|
775 | -exit:
|
|
776 | 777 | free(obuffer);
|
777 | 778 |
|
778 | 779 | return result;
|