| Summary: | rpc.yppasswdd can't deal with comments in master.passwd | ||||||
|---|---|---|---|---|---|---|---|
| Product: | Base System | Reporter: | Andre Albsmeier <Andre.Albsmeier> | ||||
| Component: | bin | Assignee: | davidn | ||||
| Status: | Closed FIXED | ||||||
| Severity: | Affects Only Me | ||||||
| Priority: | Normal | ||||||
| Version: | 3.4-STABLE | ||||||
| Hardware: | Any | ||||||
| OS: | Any | ||||||
| Attachments: |
|
||||||
|
Description
Andre Albsmeier
2000-07-03 11:30:00 UTC
Responsible Changed From-To: freebsd-bugs->davidn David likes passwd-related problems. :-) Please try the enclosed patch and test to ensure that it resolves your problem. On Tue, 11-Jul-2000 at 12:06:42 +1000, David Nugent wrote: > Please try the enclosed patch and test to ensure that it resolves your > problem. > Content-Description: pw_copy.c.diff > Executing: cvs diff -c pw_copy.c > Index: pw_copy.c > =================================================================== > RCS file: /home/ncvs/src/usr.sbin/rpc.yppasswdd/pw_copy.c,v > retrieving revision 1.4 > diff -c -r1.4 pw_copy.c > *** pw_copy.c 1999/08/28 01:19:40 1.4 > --- pw_copy.c 2000/07/11 01:59:32 > *************** > *** 90,95 **** > --- 90,105 ---- > goto err; > continue; > } > + /* > + * Just copy comments and blank lines > + */ > + p = buf + strcspn(buf, " \t\n"); > + if (*p == '\0' || *p == '#') { > + (void)fprintf(to, "%s", buf); > + if (ferror(to)) > + goto err; > + continue; > + } > if (!(p = strchr(buf, ':'))) { > yp_error("%s: corrupted entry", passfile); > pw_error(NULL, 0, 1); Adding the '#' char to " \t\n" made it work. So the line reads p = buf + strcspn(buf, "# \t\n"); -Andre Andre Albsmeier wrote:
> > + p = buf + strcspn(buf, " \t\n");
> > + if (*p == '\0' || *p == '#') {
> > + (void)fprintf(to, "%s", buf);
> > + if (ferror(to))
> > + goto err;
> > + continue;
> > + }
> > if (!(p = strchr(buf, ':'))) {
> > yp_error("%s: corrupted entry", passfile);
> > pw_error(NULL, 0, 1);
>
> Adding the '#' char to " \t\n" made it work. So the line reads
>
> p = buf + strcspn(buf, "# \t\n");
Hmm. But this would mean
# blah this is supposed to be a comment
have variable 'p' pointing at 'b' on the first 'if' statement above.
It would not be detected as a comment and it would get junked by
the next 'if'.
ACK! I see the bug. Change strcspn() to strspn() in my original
patch and try it again. Sorry about that - I've *always* confused
those two. :-) That statement is intended to skip leading whitespace
and test the next char for end of string (empty line) or the start
of a comment. If either, copy and continue, otherwise fall through
to the sanity check that caused the hiccup before.
David
State Changed From-To: open->feedback Patch submitted to user for testing. On Tue, 11-Jul-2000 at 23:23:24 +1000, David Nugent wrote: > Andre Albsmeier wrote: > > > + p = buf + strcspn(buf, " \t\n"); > > > + if (*p == '\0' || *p == '#') { > > > + (void)fprintf(to, "%s", buf); > > > + if (ferror(to)) > > > + goto err; > > > + continue; > > > + } > > > if (!(p = strchr(buf, ':'))) { > > > yp_error("%s: corrupted entry", passfile); > > > pw_error(NULL, 0, 1); > > > > Adding the '#' char to " \t\n" made it work. So the line reads > > > > p = buf + strcspn(buf, "# \t\n"); > > Hmm. But this would mean > > # blah this is supposed to be a comment > > have variable 'p' pointing at 'b' on the first 'if' statement above. > It would not be detected as a comment and it would get junked by > the next 'if'. Oops, of course... > > ACK! I see the bug. Change strcspn() to strspn() in my original > patch and try it again. Sorry about that - I've *always* confused > those two. :-) That statement is intended to skip leading whitespace > and test the next char for end of string (empty line) or the start > of a comment. If either, copy and continue, otherwise fall through > to the sanity check that caused the hiccup before. Works! Thanks a lot. -Andre > > > David -- Your mouse has moved. Windows NT must be restarted for the change to take effect! Reboot now? [OK] State Changed From-To: feedback->closed Fix committed in: Checking in pw_copy.c; /home/ncvs/src/usr.sbin/rpc.yppasswdd/pw_copy.c,v <-- pw_copy.c new revision: 1.5; previous revision: 1.4 |