~vcs-imports/busybox/trunk

« back to all changes in this revision

Viewing changes to libpwdgrp/pwd_grp.c

  • Committer: Denys Vlasenko
  • Author(s): Christian Franke
  • Date: 2023-11-13 10:32:35 UTC
  • Revision ID: git-v1:a63b60bdd6fa26b867c80d44074118babbae7ffd
Cygwin: regenerate defconfig

Signed-off-by: Christian Franke <christian.franke@t-online.de>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>

Show diffs side-by-side

added added

removed removed

Lines of Context:
191
191
        char *buf;
192
192
 
193
193
        while ((buf = xmalloc_fgetline(fp)) != NULL) {
 
194
                int n;
 
195
                char *field;
 
196
 
194
197
                /* Skip empty lines, comment lines */
195
198
                if (buf[0] == '\0' || buf[0] == '#')
196
199
                        goto free_and_next;
204
207
                        /* no key specified: sequential read, return a record */
205
208
                        break;
206
209
                }
207
 
                if (strcmp(key, nth_string(buf, field_pos)) == 0) {
 
210
                /* Can't use nth_string() here, it does not allow empty strings
 
211
                 * ("\0\0" terminates the list), and a valid passwd entry
 
212
                 * "user::UID:GID..." would be mishandled */
 
213
                n = field_pos;
 
214
                field = buf;
 
215
                while (n) {
 
216
                        n--;
 
217
                        field += strlen(field) + 1;
 
218
                }
 
219
                if (strcmp(key, field) == 0) {
208
220
                        /* record found */
209
221
                        break;
210
222
                }