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:date:message-id:subject:from:to:content-type; bh=K5pEOfyh+qETt3faIsBjpxAX67YMooCo6Lfm1Zglq6k=; b=TPZcvEJYdmfcjBsiDB1YrMz2pqcdSuX9V9NZMrHraLw9ABO1YpY3p+F1ctCi7/Mgp+ iYaojqgFlwl/UgaERLxhqswg0IywxkZkQgYAy59b3DVJR7R4XMA6zAG+K+Tes0IwpDHu 2FuSv8SAK7KORI2t/pCppqExozT9EXQnK2DVg= MIME-Version: 1.0 Date: Sat, 2 Jul 2011 18:23:44 +0300 Message-ID: Subject: [patch] kill gets() usage in stubedit.c, use fgets() From: Ozkan Sezer To: djgpp-workers AT delorie DOT com Content-Type: text/plain; charset=ISO-8859-1 Reply-To: djgpp-workers AT delorie DOT com 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. The patch below makes stubedit to use fgets() instead. Regards. Index: src/stub/stubedit.c =================================================================== RCS file: /cvs/djgpp/djgpp/src/stub/stubedit.c,v retrieving revision 1.7 diff -u -p -r1.7 stubedit.c --- src/stub/stubedit.c 5 Jan 2003 17:59:26 -0000 1.7 +++ src/stub/stubedit.c 2 Jul 2011 15:15:51 -0000 @@ -87,9 +87,20 @@ void store_info(char *filename) char *pose_question(char *question, char *default_answer) { static char response[200]; + char *ptr; printf("%s ? [%s] ", question, default_answer); fflush(stdout); - gets(response); + ptr = fgets(response, sizeof(response), stdin); + if (!ptr) + return 0; + for (; *ptr; ++ptr) + { + if (*ptr == '\n') + { + *ptr = '\0'; + break; + } + } if (response[0] == '\0') return 0; return response; -- O.S.