1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
Description: Replace deprecated gets() with std::cin.getline()
Author: Jörg Frings-Fürst <debian@jff-webhosting.net>
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=841626
Last-Update: 2016-10-22
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
Index: xbase64-3.1.2/bin/dbfutil1.cpp
===================================================================
--- xbase64-3.1.2.orig/bin/dbfutil1.cpp
+++ xbase64-3.1.2/bin/dbfutil1.cpp
@@ -38,6 +38,7 @@
*/
#include <xbase64/xbase64.h>
+#include <limits>
// next lines are helpful for debugging purposes
/*
@@ -153,11 +154,16 @@ void MyClass::FilterMenu()
/************************************************************************/
void MyClass::SetFilter()
{
- char Expression[512];
- memset( Expression, 0x00, 512 );
+ constexpr int SIZE = 512;
+
+ char Expression[SIZE];
+ memset( Expression, 0x00, SIZE );
while( !strlen( Expression )){
std::cout << "Enter filter expression (like AMOUNT<5)" << std::endl;
- gets( Expression );
+
+ std::cin.getline(Expression, SIZE-1);
+ Expression[SIZE-1] = '\0';
+ std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
}
if( xbf )
delete xbf;
@@ -235,19 +241,24 @@ void MyClass::LastFilterRec()
#ifdef XB_EXPRESSIONS
void MyClass::ProcessExpression()
{
- char exprsn[256];
+ constexpr int SIZE = 256;
+
+ char exprsn[SIZE];
char type;
xbExpn *exp; // expression
xbShort rc;
int debug = 0;
- memset( exprsn, 0x00, 256 );
+ memset( exprsn, 0x00, SIZE );
std::cout << "Enter expression string or HELP" << std::endl;
while( !strstr( exprsn, "QUIT" ) && !strstr( exprsn, "quit" )){
std::cout << ">";
- gets( exprsn );
+
+ std::cin.getline(exprsn, SIZE-1);
+ exprsn[SIZE-1] = '\0';
+ std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
if( strstr( exprsn, "HELP" ) || strstr( exprsn, "help" )){
std::cout << "** Command Help ***" << std::endl << std::endl;
|