| www.delorie.com/archives/browse.cgi | search |
| X-Authentication-Warning: | delorie.com: mail set sender to djgpp-workers-bounces using -f |
| X-Recipient: | djgpp-workers AT delorie DOT com |
| DKIM-Signature: | v=1; a=rsa-sha256; c=relaxed/relaxed; |
| d=gmail.com; s=gamma; | |
| h=mime-version:in-reply-to:references:date:message-id:subject:from:to | |
| :content-type:content-transfer-encoding; | |
| bh=wGKy3DzNVK5hPzIriVLJwc6ggFHie4briDAIogekUZo=; | |
| b=ZtKLprxTHeBIx5htboVIORjPm2nOO9lLoLmR4cqrV+Ty41EFRq1IwQLHF+/spDHBBX | |
| g1p2HIo5zZKfTNYAP7oAFuTX9+D5ZaPWyGdyqqyLVv+VefN2PbDo5guCR8/VfgHWdyGh | |
| SLxy9mBz4N1bdUlUgh/gMKrQfKAA/TPnveARM= | |
| MIME-Version: | 1.0 |
| In-Reply-To: | <BANLkTi=f2bhVUio9R4Sb60LHB0Wb5-79YQ@mail.gmail.com> |
| References: | <BANLkTimnFhfjYM=HbSmv5v7KdCkKfVLrgQ AT mail DOT gmail DOT com> |
| <201107021926 DOT 48563 DOT juan DOT guerrero AT gmx DOT de> | |
| <BANLkTi=f2bhVUio9R4Sb60LHB0Wb5-79YQ AT mail DOT gmail DOT com> | |
| Date: | Sat, 2 Jul 2011 20:47:28 +0300 |
| Message-ID: | <BANLkTin-Tt6vDw5wRu471NteTp-=4YVrUA@mail.gmail.com> |
| Subject: | Re: [patch] kill gets() usage in stubedit.c, use fgets() |
| From: | Ozkan Sezer <sezeroz AT gmail DOT com> |
| To: | djgpp-workers AT delorie DOT com |
| X-MIME-Autoconverted: | from quoted-printable to 8bit by delorie.com id p62HlZCX016256 |
| Reply-To: | djgpp-workers AT delorie DOT com |
| Errors-To: | nobody AT delorie DOT com |
| X-Mailing-List: | djgpp-workers AT delorie DOT com |
| X-Unsubscribes-To: | listserv AT delorie DOT com |
On Sat, Jul 2, 2011 at 8:40 PM, Ozkan Sezer <sezeroz AT gmail DOT com> wrote:
> On Sat, Jul 2, 2011 at 8:26 PM, Juan Manuel Guerrero
> <juan DOT guerrero AT gmx DOT de> wrote:
>> Am Samstag, 2. Juli 2011 schrieb Ozkan Sezer:
>>> Compilation of stubedit.c warns:
>>> /tmp/cc0xwkwD.o: In function `pose_question':
>>> /djgpp-20110630/src/stub/stubedit.c:92: warning: the `gets' function
>>> is dangerous and should not be used.
>> [snip]
>>
>> Are there more cases where gets is used? If so they should be fixed all
>> together.
>>
>
> Quick scanning reveals:
>
> src/utils/djtar/djtar.c: line #208: Missed this because I never use
> it, not needed in cross-tools
>
Here is a patch changing djtar.c in a similar way.
Index: djtar.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/utils/djtar/djtar.c,v
retrieving revision 1.12
diff -u -p -r1.12 djtar.c
--- djtar.c 26 Feb 2011 19:52:07 -0000 1.12
+++ djtar.c 2 Jul 2011 17:45:34 -0000
@@ -205,10 +205,19 @@ change(char *fname, const char *problem,
fprintf(log_out, " %s %s\n new name : ", problem, fname);
fflush(log_out);
new[0] = '\0';
- if (!gets(new))
+ pos = fgets(new, sizeof(new), stdin);
+ if (!pos)
Fatal("EOF while reading stdin");
+ for (; *pos; ++pos)
+ {
+ if (*pos == '\n')
+ {
+ *pos = '\0';
+ break;
+ }
+ }
- if ((strcmp(new, "") == 0) && (isadir == 2))
+ if ((new[0] == '\0') && (isadir == 2))
return 0;
if (isadir) isadir=1;
ch = (CHANGE *)xmalloc(sizeof(CHANGE));
> src/libc/dos/dir/fnsplit.c::main() line #119 (but that's only TEST code,
> not compiled into lib.)
>
>> Regards,
>> Juan M. guerrero
>>
>
> --
> O.S.
>
Regards.
--
O.S.
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |