You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by rb...@apache.org on 2001/04/09 06:57:46 UTC
cvs commit: apr/test testnames.c
rbb 01/04/08 21:57:46
Modified: test testnames.c
Log:
gets is an unsafe function, and it outputs and error message on Linux.
Using fgets makes this compile quietly.
Revision Changes Path
1.2 +2 -2 apr/test/testnames.c
Index: testnames.c
===================================================================
RCS file: /home/cvs/apr/test/testnames.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -b -w -u -r1.1 -r1.2
--- testnames.c 2001/04/08 08:08:19 1.1
+++ testnames.c 2001/04/09 04:57:46 1.2
@@ -115,10 +115,10 @@
while (1) {
fprintf(stdout, "\nEnter a root path$ ");
- if (!gets(rootpath))
+ if (!fgets(rootpath, 256, stdin))
exit(0);
fprintf(stdout, "Enter an add path$ ");
- if (!gets(addpath))
+ if (!fgets(addpath, 256, stdin))
exit(0);
merge_result(rootpath, addpath, 0);
merge_result(rootpath, addpath, APR_FILEPATH_NOTABOVEROOT);
Re: cvs commit: apr/test testnames.c
Posted by rb...@covalent.net.
> > gets is an unsafe function, and it outputs and error message on Linux.
> > Using fgets makes this compile quietly.
> >
> > - if (!gets(rootpath))
> > + if (!fgets(rootpath, 256, stdin))
> > exit(0);
> > fprintf(stdout, "Enter an add path$ ");
> > - if (!gets(addpath))
> > + if (!fgets(addpath, 256, stdin))
> > exit(0);
>
> Fair enough ... however, don't you need to eat the newline with this patch?
>
> stroff = strlen(path) - 1;
> while (stroff >= path && apr_isspace(stroff)) {
> path[stroff--] = '\0';
> }
Probably. I didn't think of that problem.
Ryan
_______________________________________________________________________________
Ryan Bloom rbb@apache.org
406 29th St.
San Francisco, CA 94131
-------------------------------------------------------------------------------
Re: cvs commit: apr/test testnames.c
Posted by "William A. Rowe, Jr." <ad...@rowe-clan.net>.
----- Original Message -----
From: <rb...@apache.org>
To: <ap...@apache.org>
Sent: Sunday, April 08, 2001 11:57 PM
Subject: cvs commit: apr/test testnames.c
> rbb 01/04/08 21:57:46
>
> Modified: test testnames.c
> Log:
> gets is an unsafe function, and it outputs and error message on Linux.
> Using fgets makes this compile quietly.
>
> - if (!gets(rootpath))
> + if (!fgets(rootpath, 256, stdin))
> exit(0);
> fprintf(stdout, "Enter an add path$ ");
> - if (!gets(addpath))
> + if (!fgets(addpath, 256, stdin))
> exit(0);
Fair enough ... however, don't you need to eat the newline with this patch?
stroff = strlen(path) - 1;
while (stroff >= path && apr_isspace(stroff)) {
path[stroff--] = '\0';
}