checked/changed all sprintf calls
This commit is contained in:
parent
c34e945299
commit
061ffda545
@ -23,6 +23,7 @@ static char rcsid[] = "@(#$Id: rclconfig.cpp,v 1.62 2008-10-08 16:15:22 dockes E
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <langinfo.h>
|
#include <langinfo.h>
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@ -959,9 +960,10 @@ static int ncffiles = sizeof(configfiles) / sizeof(char *);
|
|||||||
bool RclConfig::initUserConfig()
|
bool RclConfig::initUserConfig()
|
||||||
{
|
{
|
||||||
// Explanatory text
|
// Explanatory text
|
||||||
char blurb[sizeof(blurb0)+1025];
|
const int bs = sizeof(blurb0)+PATH_MAX+1;
|
||||||
|
char blurb[bs];
|
||||||
string exdir = path_cat(m_datadir, "examples");
|
string exdir = path_cat(m_datadir, "examples");
|
||||||
sprintf(blurb, blurb0, exdir.c_str());
|
snprintf(blurb, bs, blurb0, exdir.c_str());
|
||||||
|
|
||||||
// Use protective 700 mode to create the top configuration
|
// Use protective 700 mode to create the top configuration
|
||||||
// directory: documents can be reconstructed from index data.
|
// directory: documents can be reconstructed from index data.
|
||||||
|
|||||||
@ -398,7 +398,7 @@ BeagleQueueIndexer::processone(const string &path,
|
|||||||
make_udi(udipath, "", udi);
|
make_udi(udipath, "", udi);
|
||||||
|
|
||||||
LOGDEB(("BeagleQueueIndexer: prc1: udi [%s]\n", udi.c_str()));
|
LOGDEB(("BeagleQueueIndexer: prc1: udi [%s]\n", udi.c_str()));
|
||||||
char ascdate[20];
|
char ascdate[30];
|
||||||
sprintf(ascdate, "%ld", long(stp->st_mtime));
|
sprintf(ascdate, "%ld", long(stp->st_mtime));
|
||||||
|
|
||||||
// We only process bookmarks or text/html and text/plain files.
|
// We only process bookmarks or text/html and text/plain files.
|
||||||
|
|||||||
@ -399,7 +399,7 @@ FsIndexer::processone(const std::string &fn, const struct stat *stp,
|
|||||||
make_udi(fn, "", parent_udi);
|
make_udi(fn, "", parent_udi);
|
||||||
Rcl::Doc doc;
|
Rcl::Doc doc;
|
||||||
const string plus("+");
|
const string plus("+");
|
||||||
char ascdate[20];
|
char ascdate[30];
|
||||||
sprintf(ascdate, "%ld", long(stp->st_mtime));
|
sprintf(ascdate, "%ld", long(stp->st_mtime));
|
||||||
|
|
||||||
FileInterner::Status fis = FileInterner::FIAgain;
|
FileInterner::Status fis = FileInterner::FIAgain;
|
||||||
|
|||||||
@ -242,7 +242,7 @@ const char *RclFAM::event_name(int code)
|
|||||||
"FAMExists",
|
"FAMExists",
|
||||||
"FAMEndExist"
|
"FAMEndExist"
|
||||||
};
|
};
|
||||||
static char unknown_event[20];
|
static char unknown_event[30];
|
||||||
|
|
||||||
if (code < FAMChanged || code > FAMEndExist) {
|
if (code < FAMChanged || code > FAMEndExist) {
|
||||||
sprintf(unknown_event, "unknown (%d)", code);
|
sprintf(unknown_event, "unknown (%d)", code);
|
||||||
|
|||||||
@ -288,7 +288,7 @@ bool MimeHandlerMail::processAttach()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ipath
|
// Ipath
|
||||||
char nbuf[10];
|
char nbuf[20];
|
||||||
sprintf(nbuf, "%d", m_idx);
|
sprintf(nbuf, "%d", m_idx);
|
||||||
m_metaData["ipath"] = nbuf;
|
m_metaData["ipath"] = nbuf;
|
||||||
|
|
||||||
|
|||||||
@ -140,7 +140,7 @@ bool MimeHandlerText::next_document()
|
|||||||
// first chunk). This is a hack. The right thing to do would
|
// first chunk). This is a hack. The right thing to do would
|
||||||
// be to use a different mtype for files over the page size,
|
// be to use a different mtype for files over the page size,
|
||||||
// and keep text/plain only for smaller files.
|
// and keep text/plain only for smaller files.
|
||||||
char buf[20];
|
char buf[30];
|
||||||
sprintf(buf, "%lld", (long long)(m_offs - m_text.length()));
|
sprintf(buf, "%lld", (long long)(m_offs - m_text.length()));
|
||||||
if (m_offs - m_text.length() != 0)
|
if (m_offs - m_text.length() != 0)
|
||||||
m_metaData["ipath"] = buf;
|
m_metaData["ipath"] = buf;
|
||||||
|
|||||||
@ -35,8 +35,8 @@ static char rcsid[] = "@(#$Id: docseqhist.cpp,v 1.4 2008-09-29 08:59:20 dockes E
|
|||||||
// The U distinguishes udi-based entries from older fn+ipath ones
|
// The U distinguishes udi-based entries from older fn+ipath ones
|
||||||
bool RclDHistoryEntry::encode(string& value)
|
bool RclDHistoryEntry::encode(string& value)
|
||||||
{
|
{
|
||||||
char chartime[20];
|
char chartime[30];
|
||||||
sprintf(chartime, "%ld", unixtime);
|
sprintf(chartime,"%ld", unixtime);
|
||||||
string budi;
|
string budi;
|
||||||
base64_encode(udi, budi);
|
base64_encode(udi, budi);
|
||||||
value = string("U ") + string(chartime) + " " + budi;
|
value = string("U ") + string(chartime) + " " + budi;
|
||||||
|
|||||||
@ -75,6 +75,12 @@ public:
|
|||||||
{
|
{
|
||||||
return append(data);
|
return append(data);
|
||||||
}
|
}
|
||||||
|
// Translation function. This is reimplemented in the qt reslist
|
||||||
|
// object For this to work, the strings must be duplicated inside
|
||||||
|
// reslist.cpp (see the QT_TR_NOOP in there). Very very unwieldy.
|
||||||
|
// To repeat: any change to a string used with trans() inside
|
||||||
|
// reslistpager.cpp must be reflected in the string table inside
|
||||||
|
// reslist.cpp for translation to work.
|
||||||
virtual string trans(const string& in);
|
virtual string trans(const string& in);
|
||||||
virtual string detailsLink();
|
virtual string detailsLink();
|
||||||
virtual const string &parFormat();
|
virtual const string &parFormat();
|
||||||
|
|||||||
@ -988,7 +988,8 @@ bool Db::addOrUpdate(const string &udi, const string &parent_udi,
|
|||||||
doc.dmtime.c_str());
|
doc.dmtime.c_str());
|
||||||
struct tm *tm = localtime(&mtime);
|
struct tm *tm = localtime(&mtime);
|
||||||
char buf[9];
|
char buf[9];
|
||||||
sprintf(buf, "%04d%02d%02d",tm->tm_year+1900, tm->tm_mon + 1, tm->tm_mday);
|
snprintf(buf, 9, "%04d%02d%02d",
|
||||||
|
tm->tm_year+1900, tm->tm_mon + 1, tm->tm_mday);
|
||||||
newdocument.add_term("D" + string(buf)); // Date (YYYYMMDD)
|
newdocument.add_term("D" + string(buf)); // Date (YYYYMMDD)
|
||||||
buf[6] = '\0';
|
buf[6] = '\0';
|
||||||
newdocument.add_term("M" + string(buf)); // Month (YYYYMM)
|
newdocument.add_term("M" + string(buf)); // Month (YYYYMM)
|
||||||
|
|||||||
@ -391,7 +391,8 @@ public:
|
|||||||
{
|
{
|
||||||
char bf[CIRCACHE_HEADER_SIZE];
|
char bf[CIRCACHE_HEADER_SIZE];
|
||||||
memset(bf, 0, CIRCACHE_HEADER_SIZE);
|
memset(bf, 0, CIRCACHE_HEADER_SIZE);
|
||||||
sprintf(bf, headerformat, d.dicsize, d.datasize, d.padsize, d.flags);
|
snprintf(bf, CIRCACHE_HEADER_SIZE,
|
||||||
|
headerformat, d.dicsize, d.datasize, d.padsize, d.flags);
|
||||||
if (lseek(m_fd, offset, 0) != offset) {
|
if (lseek(m_fd, offset, 0) != offset) {
|
||||||
m_reason << "CirCache::weh: lseek(" << offset <<
|
m_reason << "CirCache::weh: lseek(" << offset <<
|
||||||
") failed: errno " << errno;
|
") failed: errno " << errno;
|
||||||
@ -1000,7 +1001,8 @@ bool CirCache::put(const string& udi, const ConfSimple *iconf,
|
|||||||
|
|
||||||
char head[CIRCACHE_HEADER_SIZE];
|
char head[CIRCACHE_HEADER_SIZE];
|
||||||
memset(head, 0, CIRCACHE_HEADER_SIZE);
|
memset(head, 0, CIRCACHE_HEADER_SIZE);
|
||||||
sprintf(head, headerformat, dic.size(), datalen, npadsize, flags);
|
snprintf(head, CIRCACHE_HEADER_SIZE,
|
||||||
|
headerformat, dic.size(), datalen, npadsize, flags);
|
||||||
struct iovec vecs[3];
|
struct iovec vecs[3];
|
||||||
vecs[0].iov_base = head;
|
vecs[0].iov_base = head;
|
||||||
vecs[0].iov_len = CIRCACHE_HEADER_SIZE;
|
vecs[0].iov_len = CIRCACHE_HEADER_SIZE;
|
||||||
|
|||||||
@ -182,12 +182,12 @@ static bool fileInFiles(const string& file)
|
|||||||
|
|
||||||
#ifdef _WINDOWS
|
#ifdef _WINDOWS
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
static void datestring(char *d) {
|
static void datestring(char *d, int sz) {
|
||||||
SYSTEMTIME buf;
|
SYSTEMTIME buf;
|
||||||
GetLocalTime(&buf);
|
GetLocalTime(&buf);
|
||||||
int year = buf.wYear % 100;
|
int year = buf.wYear % 100;
|
||||||
|
|
||||||
sprintf(d, "%02d%02d%02d%02d%02d%02d", year, int(buf.wMonth),
|
snprintf(d, sz, "%02d%02d%02d%02d%02d%02d", year, int(buf.wMonth),
|
||||||
int(buf.wDay), int(buf.wHour), int(buf.wMinute), int(buf.wSecond));
|
int(buf.wDay), int(buf.wHour), int(buf.wMinute), int(buf.wSecond));
|
||||||
}
|
}
|
||||||
#define vsnprintf _vsnprintf
|
#define vsnprintf _vsnprintf
|
||||||
@ -195,13 +195,13 @@ static void datestring(char *d) {
|
|||||||
#else // !WINDOWS ->
|
#else // !WINDOWS ->
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
static void datestring(char *d)
|
static void datestring(char *d, int sz)
|
||||||
{
|
{
|
||||||
struct tm *tmp;
|
struct tm *tmp;
|
||||||
time_t tim = time((time_t)0);
|
time_t tim = time((time_t)0);
|
||||||
tmp = localtime(&tim);
|
tmp = localtime(&tim);
|
||||||
int year = tmp->tm_year % 100;
|
int year = tmp->tm_year % 100;
|
||||||
sprintf(d, "%02d%02d%02d%02d%02d%02d", year, tmp->tm_mon+1,
|
snprintf(d, sz, "%02d%02d%02d%02d%02d%02d", year, tmp->tm_mon+1,
|
||||||
tmp->tm_mday, tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
|
tmp->tm_mday, tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,7 +220,7 @@ DebugLog::prolog(int lev, const char *f, int line)
|
|||||||
}
|
}
|
||||||
if (dodate) {
|
if (dodate) {
|
||||||
char dts[100];
|
char dts[100];
|
||||||
datestring(dts);
|
datestring(dts, 100);
|
||||||
writer->put(dts);
|
writer->put(dts);
|
||||||
}
|
}
|
||||||
char buf[100];
|
char buf[100];
|
||||||
|
|||||||
@ -389,7 +389,7 @@ int NetconData::send(const char *buf, int cnt, int expedited)
|
|||||||
|
|
||||||
// Note: byte count may be different from cnt if fd is non-blocking
|
// Note: byte count may be different from cnt if fd is non-blocking
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
char fdcbuf[10];sprintf(fdcbuf, "%d", m_fd);
|
char fdcbuf[20];sprintf(fdcbuf, "%d", m_fd);
|
||||||
LOGSYSERR("NetconData::send", "send", fdcbuf);
|
LOGSYSERR("NetconData::send", "send", fdcbuf);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
@ -453,7 +453,7 @@ int NetconData::receive(char *buf, int cnt, int timeo)
|
|||||||
}
|
}
|
||||||
m_didtimo = 0;
|
m_didtimo = 0;
|
||||||
if ((cnt = read(m_fd, buf + fromibuf, cnt)) < 0) {
|
if ((cnt = read(m_fd, buf + fromibuf, cnt)) < 0) {
|
||||||
char fdcbuf[10];sprintf(fdcbuf, "%d", m_fd);
|
char fdcbuf[20];sprintf(fdcbuf, "%d", m_fd);
|
||||||
LOGSYSERR("NetconData::receive", "read", fdcbuf);
|
LOGSYSERR("NetconData::receive", "read", fdcbuf);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -49,7 +49,7 @@ static void caterrno(string *reason, const char *what, int _errno)
|
|||||||
if (reason) {
|
if (reason) {
|
||||||
reason->append(what);
|
reason->append(what);
|
||||||
reason->append(": errno: ");
|
reason->append(": errno: ");
|
||||||
char nbuf[10];
|
char nbuf[20];
|
||||||
sprintf(nbuf, "%d", _errno);
|
sprintf(nbuf, "%d", _errno);
|
||||||
reason->append(nbuf);
|
reason->append(nbuf);
|
||||||
reason->append(" : ");
|
reason->append(" : ");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user