Splint fiddles.
CVS patchset: 7435 CVS date: 2004/10/09 17:29:22
This commit is contained in:
parent
d8822ba626
commit
b831315e41
|
@ -7,6 +7,7 @@ Makefile.in
|
|||
*.la
|
||||
*.lcd
|
||||
*.lo
|
||||
tax
|
||||
tdigest
|
||||
tdir
|
||||
tficl
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
+bounds
|
||||
-bufferoverflowhigh
|
||||
|
||||
|
||||
# --- +partial artifacts
|
||||
-declundef
|
||||
-exportheadervar
|
||||
|
|
|
@ -4,24 +4,23 @@ AUTOMAKE_OPTIONS = 1.4 foreign
|
|||
|
||||
LINT = splint
|
||||
|
||||
EXTRA_DIST = tdigest.c tdir.c tficl.c tfts.c tglob.c tinv.c tkey.c trpmio.c
|
||||
EXTRA_DIST = tax.c tdigest.c tdir.c tficl.c tfts.c tglob.c tinv.c tkey.c trpmio.c
|
||||
|
||||
EXTRA_PROGRAMS = tdigest tdir tfts tglob tinv tkey tring trpmio tsw dumpasn1
|
||||
EXTRA_PROGRAMS = tax tdigest tdir tfts tglob tinv tkey tring trpmio tsw dumpasn1
|
||||
|
||||
INCLUDES = -I. \
|
||||
-I$(top_srcdir) \
|
||||
@WITH_BEECRYPT_INCLUDE@ \
|
||||
@WITH_LUA_INCLUDE@ \
|
||||
-I$(top_srcdir)/popt \
|
||||
-I$(top_srcdir)/lua/include \
|
||||
-I$(top_srcdir)/lua/local \
|
||||
@INCPATH@
|
||||
|
||||
pkgincdir = $(pkgincludedir)
|
||||
pkginc_HEADERS = \
|
||||
argv.h fts.h \
|
||||
rpmio.h rpmurl.h rpmmacro.h rpmlog.h rpmmessages.h rpmerr.h rpmpgp.h \
|
||||
rpmsq.h rpmsw.h ugid.h rpmlua.h rpmhook.h
|
||||
noinst_HEADERS = rpmio_internal.h
|
||||
rpmsq.h rpmsw.h ugid.h
|
||||
noinst_HEADERS = rpmio_internal.h rpmlua.h rpmhook.h
|
||||
|
||||
BEECRYPTLOBJS = $(shell test X"@WITH_BEECRYPT_SUBDIR@" != X && cat $(top_builddir)/@WITH_BEECTYPT_SUBDIR@/listobjs)
|
||||
|
||||
|
@ -31,13 +30,12 @@ usrlibdir = $(libdir)@MARK64@
|
|||
usrlib_LTLIBRARIES = librpmio.la
|
||||
librpmio_la_SOURCES = \
|
||||
argv.c digest.c fts.c macro.c \
|
||||
rpmio.c rpmlog.c rpmmalloc.c \
|
||||
rpmpgp.c rpmrpc.c rpmsq.c rpmsw.c strcasecmp.c stubs.c url.c ugid.c \
|
||||
rpmlua.c rpmhook.c
|
||||
rpmhook.c rpmio.c rpmlog.c rpmlua.c rpmmalloc.c \
|
||||
rpmpgp.c rpmrpc.c rpmsq.c rpmsw.c strcasecmp.c stubs.c url.c ugid.c
|
||||
librpmio_la_LDFLAGS = -release 4.3 $(LDFLAGS) \
|
||||
@WITH_BEECRYPT_LIB@ \
|
||||
@WITH_LUA_LIB@ \
|
||||
$(top_builddir)/file/src/libfmagic.la \
|
||||
$(top_builddir)/lua/liblua.la \
|
||||
@WITH_ZLIB_LIB@ \
|
||||
-lrt -lpthread
|
||||
librpmio_la_LIBADD = # $(BEECRYPTLOBJS)
|
||||
|
@ -68,6 +66,9 @@ sources:
|
|||
lint:
|
||||
$(LINT) $(DEFS) $(INCLUDES) $(librpmio_la_SOURCES)
|
||||
|
||||
tax_SOURCES = tax.c
|
||||
tax_LDADD = librpmio.la
|
||||
|
||||
tdigest_SOURCES = tdigest.c
|
||||
tdigest_LDADD = librpmio.la $(top_builddir)/popt/libpopt.la -lgcrypt
|
||||
|
||||
|
|
|
@ -43,7 +43,10 @@ typedef FILE * FD_t;
|
|||
#include <rpmio_internal.h>
|
||||
#include <rpmmessages.h>
|
||||
#include <rpmerr.h>
|
||||
|
||||
#ifdef WITH_LUA
|
||||
#include <rpmlua.h>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1404,6 +1407,7 @@ expandMacro(MacroBuf mb)
|
|||
continue;
|
||||
}
|
||||
|
||||
#ifdef WITH_LUA
|
||||
if (STREQ("lua", f, fn)) {
|
||||
rpmlua lua = NULL; /* Global state. */
|
||||
const char *ls = s+sizeof("{lua:")-1;
|
||||
|
@ -1429,6 +1433,7 @@ expandMacro(MacroBuf mb)
|
|||
s = se;
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* XXX necessary but clunky */
|
||||
if (STREQ("basename", f, fn) ||
|
||||
|
@ -1793,7 +1798,7 @@ exit:
|
|||
}
|
||||
/*@=branchstate@*/
|
||||
#endif
|
||||
av = _free(av);
|
||||
av = _free(av);
|
||||
/*@-branchstate@*/
|
||||
if (rc || argvPtr == NULL) {
|
||||
/*@-dependenttrans -unqualifiedtrans@*/
|
||||
|
|
|
@ -41,7 +41,8 @@ rpmhookArgs rpmhookArgsNew(int argc)
|
|||
|
||||
rpmhookArgs rpmhookArgsFree(rpmhookArgs args)
|
||||
{
|
||||
free(args);
|
||||
if (args != NULL)
|
||||
free(args);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -156,8 +157,8 @@ static void rpmhookTableAddItem(rpmhookTable *table, const char *name,
|
|||
}
|
||||
|
||||
static void rpmhookTableDelItem(rpmhookTable *table, const char *name,
|
||||
rpmhookFunc func, void *data,
|
||||
int matchfunc, int matchdata)
|
||||
/*@null@*/ rpmhookFunc func, /*@null@*/ void *data,
|
||||
int matchfunc, int matchdata)
|
||||
/*@modifies *table @*/
|
||||
{
|
||||
int n = rpmhookTableFindBucket(table, name);
|
||||
|
|
|
@ -21,7 +21,8 @@ typedef int (*rpmhookFunc) (rpmhookArgs args, void *data);
|
|||
/*@only@*/
|
||||
rpmhookArgs rpmhookArgsNew(int argc)
|
||||
/*@*/;
|
||||
rpmhookArgs rpmhookArgsFree(/*@only@*/ rpmhookArgs args)
|
||||
/*@null@*/
|
||||
rpmhookArgs rpmhookArgsFree(/*@only@*/ /*@null@*/ rpmhookArgs args)
|
||||
/*@modifies args @*/;
|
||||
|
||||
void rpmhookRegister(const char *name, rpmhookFunc func, void *data)
|
||||
|
|
|
@ -508,9 +508,9 @@ int fdWritable(FD_t fd, int secs)
|
|||
tvp->tv_usec = 0;
|
||||
}
|
||||
FD_SET(fdno, &wrfds);
|
||||
/*@-compdef -nullpass@*/
|
||||
/*@-compdef -nullpass@*/
|
||||
rc = select(fdno + 1, NULL, &wrfds, NULL, tvp);
|
||||
/*@=compdef =nullpass@*/
|
||||
/*@=compdef =nullpass@*/
|
||||
#endif
|
||||
|
||||
if (_rpmio_debug && !(rc == 1 && errno == 0))
|
||||
|
@ -2213,7 +2213,7 @@ static int gzdFlush(FD_t fd)
|
|||
/* =============================================================== */
|
||||
static ssize_t gzdRead(void * cookie, /*@out@*/ char * buf, size_t count)
|
||||
/*@globals fileSystem, internalState @*/
|
||||
/*@modifies *buf, fileSystem, internalState @*/
|
||||
/*@modifies buf, fileSystem, internalState @*/
|
||||
{
|
||||
FD_t fd = c2f(cookie);
|
||||
gzFile gzfile;
|
||||
|
|
|
@ -1,16 +1,18 @@
|
|||
/*@-bounds -realcompare -sizeoftype -protoparammatch @*/
|
||||
#include "system.h"
|
||||
|
||||
#ifdef WITH_LUA
|
||||
#include <rpmio.h>
|
||||
#include <rpmmacro.h>
|
||||
#include <rpmerr.h>
|
||||
#include <rpmurl.h>
|
||||
#include <rpmhook.h>
|
||||
|
||||
#include "../lua/include/lua.h"
|
||||
#include "../lua/include/lualib.h"
|
||||
#include "../lua/include/lauxlib.h"
|
||||
#include "../lua/local/lposix.h"
|
||||
#include "../lua/local/lrexlib.h"
|
||||
#include <lua.h>
|
||||
#include <lualib.h>
|
||||
#include <lauxlib.h>
|
||||
#include <lposix.h>
|
||||
#include <lrexlib.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <assert.h>
|
||||
|
@ -838,5 +840,6 @@ static int luaopen_rpm(lua_State *L)
|
|||
luaL_openlib(L, "rpm", rpmlib, 0);
|
||||
return 0;
|
||||
}
|
||||
#endif /* WITH_LUA */
|
||||
|
||||
/*@=bounds =realcompare =sizeoftype =protoparammatch @*/
|
||||
|
|
|
@ -326,7 +326,7 @@ const char * pgpMpiHex(const byte *p)
|
|||
static int pgpHexSet(const char * pre, int lbits,
|
||||
/*@out@*/ mpnumber * mpn, const byte * p, const byte * pend)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies *mpn, fileSystem @*/
|
||||
/*@modifies mpn, fileSystem @*/
|
||||
{
|
||||
unsigned int mbits = pgpMpiBits(p);
|
||||
unsigned int nbits;
|
||||
|
@ -348,7 +348,7 @@ fprintf(stderr, "*** mbits %u nbits %u nbytes %u t %p[%d] ix %u\n", mbits, nbits
|
|||
strcpy(t+ix, pgpMpiHex(p));
|
||||
if (_debug)
|
||||
fprintf(stderr, "*** %s %s\n", pre, t);
|
||||
mpnsethex(mpn, t);
|
||||
(void) mpnsethex(mpn, t);
|
||||
t = _free(t);
|
||||
if (_debug && _print)
|
||||
fprintf(stderr, "\t %s ", pre), mpfprintln(stderr, mpn->size, mpn->data);
|
||||
|
@ -481,7 +481,7 @@ static int pgpPrtSigParams(/*@unused@*/ pgpTag tag, byte pubkey_algo, byte sigty
|
|||
{
|
||||
switch (i) {
|
||||
case 0: /* m**d */
|
||||
mpnsethex(&_dig->c, pgpMpiHex(p));
|
||||
(void) mpnsethex(&_dig->c, pgpMpiHex(p));
|
||||
if (_debug && _print)
|
||||
fprintf(stderr, "\t m**d = "), mpfprintln(stderr, _dig->c.size, _dig->c.data);
|
||||
/*@switchbreak@*/ break;
|
||||
|
@ -689,7 +689,7 @@ static const byte * pgpPrtPubkeyParams(byte pubkey_algo,
|
|||
if (_dig) {
|
||||
switch (i) {
|
||||
case 0: /* n */
|
||||
mpbsethex(&_dig->rsa_pk.n, pgpMpiHex(p));
|
||||
(void) mpbsethex(&_dig->rsa_pk.n, pgpMpiHex(p));
|
||||
/* Get the keyid */
|
||||
if (_digp) {
|
||||
uint32_t* np = _dig->rsa_pk.n.modl;
|
||||
|
@ -708,7 +708,7 @@ if (_debug && _print)
|
|||
fprintf(stderr, "\t n = "), mpfprintln(stderr, _dig->rsa_pk.n.size, _dig->rsa_pk.n.modl);
|
||||
/*@switchbreak@*/ break;
|
||||
case 1: /* e */
|
||||
mpnsethex(&_dig->rsa_pk.e, pgpMpiHex(p));
|
||||
(void) mpnsethex(&_dig->rsa_pk.e, pgpMpiHex(p));
|
||||
if (_debug && _print)
|
||||
fprintf(stderr, "\t e = "), mpfprintln(stderr, _dig->rsa_pk.e.size, _dig->rsa_pk.e.data);
|
||||
/*@switchbreak@*/ break;
|
||||
|
@ -722,22 +722,22 @@ fprintf(stderr, "\t e = "), mpfprintln(stderr, _dig->rsa_pk.e.size, _dig->r
|
|||
if (_dig) {
|
||||
switch (i) {
|
||||
case 0: /* p */
|
||||
mpbsethex(&_dig->p, pgpMpiHex(p));
|
||||
(void) mpbsethex(&_dig->p, pgpMpiHex(p));
|
||||
if (_debug && _print)
|
||||
fprintf(stderr, "\t p = "), mpfprintln(stderr, _dig->p.size, _dig->p.modl);
|
||||
/*@switchbreak@*/ break;
|
||||
case 1: /* q */
|
||||
mpbsethex(&_dig->q, pgpMpiHex(p));
|
||||
(void) mpbsethex(&_dig->q, pgpMpiHex(p));
|
||||
if (_debug && _print)
|
||||
fprintf(stderr, "\t q = "), mpfprintln(stderr, _dig->q.size, _dig->q.modl);
|
||||
/*@switchbreak@*/ break;
|
||||
case 2: /* g */
|
||||
mpnsethex(&_dig->g, pgpMpiHex(p));
|
||||
(void) mpnsethex(&_dig->g, pgpMpiHex(p));
|
||||
if (_debug && _print)
|
||||
fprintf(stderr, "\t g = "), mpfprintln(stderr, _dig->g.size, _dig->g.data);
|
||||
/*@switchbreak@*/ break;
|
||||
case 3: /* y */
|
||||
mpnsethex(&_dig->y, pgpMpiHex(p));
|
||||
(void) mpnsethex(&_dig->y, pgpMpiHex(p));
|
||||
if (_debug && _print)
|
||||
fprintf(stderr, "\t y = "), mpfprintln(stderr, _dig->y.size, _dig->y.data);
|
||||
/*@switchbreak@*/ break;
|
||||
|
@ -1229,10 +1229,14 @@ pgpArmor pgpReadPkts(const char * fn, const byte ** pkt, size_t * pktlen)
|
|||
if (!TOKEQ(t, "-----\n"))
|
||||
goto exit;
|
||||
|
||||
crcdec = NULL;
|
||||
crclen = 0;
|
||||
if (b64decode(crcenc, (void **)&crcdec, &crclen) != 0)
|
||||
continue;
|
||||
crcpkt = pgpGrab(crcdec, crclen);
|
||||
crcdec = _free(crcdec);
|
||||
dec = NULL;
|
||||
declen = 0;
|
||||
if (b64decode(enc, (void **)&dec, &declen) != 0)
|
||||
goto exit;
|
||||
crc = pgpCRC(dec, declen);
|
||||
|
@ -1305,7 +1309,9 @@ char * pgpArmorWrap(int atype, const unsigned char * s, size_t ns)
|
|||
t = stpcpy(t, "-----\n");
|
||||
/*@=boundswrite@*/
|
||||
|
||||
/*@-globstate@*/ /* XXX b64encode_eolstr */
|
||||
return val;
|
||||
/*@=globstate@*/
|
||||
}
|
||||
|
||||
/*@=boundsread@*/
|
||||
|
|
|
@ -52,4 +52,4 @@
|
|||
+boolint #
|
||||
+charint #
|
||||
+ignorequals #
|
||||
+matchanyintegral #
|
||||
#+matchanyintegral #
|
||||
|
|
|
@ -11,12 +11,12 @@
|
|||
#include <string.h>
|
||||
#include "sexp.h"
|
||||
|
||||
/*@access sexpIter @*/
|
||||
/*@access sexpSimpleString @*/
|
||||
|
||||
/*@access sexpList @*/
|
||||
/*@access sexpString @*/
|
||||
/*@access sexpObject @*/
|
||||
/*@access sexpList @*/
|
||||
|
||||
/*@access sexpObject @*/ /* XXX for casts only */
|
||||
/*@access sexpIter @*/ /* XXX for casts only */
|
||||
|
||||
/******************/
|
||||
/* ERROR MESSAGES */
|
||||
|
@ -76,7 +76,8 @@ void * sexpAlloc(size_t n)
|
|||
*/
|
||||
sexpSimpleString newSimpleString(void)
|
||||
{
|
||||
sexpSimpleString ss = (sexpSimpleString) sexpAlloc(sizeof(*ss));
|
||||
sexpSimpleString ss = sexpAlloc(sizeof(*ss));
|
||||
|
||||
ss->length = 0;
|
||||
ss->allocatedLength = 16;
|
||||
ss->string = sexpAlloc(16);
|
||||
|
@ -86,7 +87,7 @@ sexpSimpleString newSimpleString(void)
|
|||
/* simpleStringLength(ss)
|
||||
* returns length of simple string
|
||||
*/
|
||||
long int simpleStringLength(sexpSimpleString ss)
|
||||
size_t simpleStringLength(sexpSimpleString ss)
|
||||
{
|
||||
return ss->length;
|
||||
}
|
||||
|
@ -110,7 +111,7 @@ sexpSimpleString reallocateSimpleString(sexpSimpleString ss)
|
|||
if (ss == NULL) return NULL;
|
||||
}
|
||||
if (ss->string == NULL)
|
||||
ss->string = (octet *)sexpAlloc(16);
|
||||
ss->string = sexpAlloc(16);
|
||||
else {
|
||||
size_t newsize = 16 + 3*(ss->length)/2;
|
||||
octet * newstring = sexpAlloc(newsize);
|
||||
|
|
|
@ -367,9 +367,9 @@ void scanQuotedString(sexpInputStream is, sexpSimpleString ss, long int length)
|
|||
{
|
||||
int c;
|
||||
skipChar(is,'"');
|
||||
while (length == -1 || simpleStringLength(ss) <= length) {
|
||||
while (length == -1L || simpleStringLength(ss) <= length) {
|
||||
if (is->nextChar == '\"') {
|
||||
if (length == -1 || (simpleStringLength(ss) == length)) {
|
||||
if (length == -1L || simpleStringLength(ss) == length) {
|
||||
skipChar(is,'\"');
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -208,13 +208,13 @@ void printDecimal(sexpOutputStream os, long int n)
|
|||
void canonicalPrintVerbatimSimpleString(sexpOutputStream os, sexpSimpleString ss)
|
||||
{
|
||||
octet * c = simpleStringString(ss);
|
||||
long int len = simpleStringLength(ss);
|
||||
long int i;
|
||||
size_t len = simpleStringLength(ss);
|
||||
size_t i;
|
||||
|
||||
if (c == NULL)
|
||||
ErrorMessage(ERROR, "Can't print NULL string verbatim");
|
||||
/* print out len: */
|
||||
printDecimal(os, len);
|
||||
printDecimal(os, (long int)len);
|
||||
varPutChar(os, ':');
|
||||
/* print characters in fragment */
|
||||
for (i=0; i<len; i++) varPutChar(os, (int)*c++);
|
||||
|
@ -298,12 +298,14 @@ void base64PrintWholeObject(sexpOutputStream os, sexpObject object)
|
|||
*/
|
||||
int canPrintAsToken(sexpOutputStream os, sexpSimpleString ss)
|
||||
{
|
||||
long int len = simpleStringLength(ss);
|
||||
octet * c = simpleStringString(ss);
|
||||
int i;
|
||||
size_t len = simpleStringLength(ss);
|
||||
size_t i;
|
||||
|
||||
if (c == NULL) return FALSE;
|
||||
/*@-unsignedcompare@*/ /* XXX len now unsigned size_t. */
|
||||
if (len <= 0) return FALSE;
|
||||
/*@=unsignedcompare@*/
|
||||
if (isDecDigit((int)*c)) return FALSE;
|
||||
if (os->maxcolumn > 0 && os->column + len >= os->maxcolumn)
|
||||
return FALSE;
|
||||
|
@ -318,9 +320,9 @@ int canPrintAsToken(sexpOutputStream os, sexpSimpleString ss)
|
|||
*/
|
||||
void advancedPrintTokenSimpleString(sexpOutputStream os, sexpSimpleString ss)
|
||||
{
|
||||
long int len = simpleStringLength(ss);
|
||||
octet * c = simpleStringString(ss);
|
||||
int i;
|
||||
size_t len = simpleStringLength(ss);
|
||||
size_t i;
|
||||
|
||||
if (os->maxcolumn>0 && os->column > (os->maxcolumn - len))
|
||||
os->newLine(os, ADVANCED);
|
||||
|
@ -331,7 +333,7 @@ void advancedPrintTokenSimpleString(sexpOutputStream os, sexpSimpleString ss)
|
|||
/* advancedLengthSimpleStringToken(ss)
|
||||
* Returns length for printing simple string ss as a token
|
||||
*/
|
||||
int advancedLengthSimpleStringToken(sexpSimpleString ss)
|
||||
size_t advancedLengthSimpleStringToken(sexpSimpleString ss)
|
||||
{
|
||||
return simpleStringLength(ss);
|
||||
}
|
||||
|
@ -345,26 +347,26 @@ int advancedLengthSimpleStringToken(sexpSimpleString ss)
|
|||
*/
|
||||
void advancedPrintVerbatimSimpleString(sexpOutputStream os, sexpSimpleString ss)
|
||||
{
|
||||
long int len = simpleStringLength(ss);
|
||||
octet * c = simpleStringString(ss);
|
||||
long int i;
|
||||
size_t len = simpleStringLength(ss);
|
||||
size_t i;
|
||||
|
||||
if (c == NULL)
|
||||
ErrorMessage(ERROR, "Can't print NULL string verbatim");
|
||||
if (os->maxcolumn>0 && os->column > (os->maxcolumn - len))
|
||||
os->newLine(os, ADVANCED);
|
||||
printDecimal(os,len);
|
||||
os->putChar(os,':');
|
||||
printDecimal(os, (long int)len);
|
||||
os->putChar(os, ':');
|
||||
for (i=0; i<len; i++) os->putChar(os, (int)*c++);
|
||||
}
|
||||
|
||||
/* advancedLengthSimpleStringVerbatim(ss)
|
||||
* Returns length for printing simple string ss in verbatim mode
|
||||
*/
|
||||
int advancedLengthSimpleStringVerbatim(sexpSimpleString ss)
|
||||
size_t advancedLengthSimpleStringVerbatim(sexpSimpleString ss)
|
||||
{
|
||||
long int len = simpleStringLength(ss);
|
||||
int i = 1;
|
||||
size_t len = simpleStringLength(ss);
|
||||
size_t i = 1;
|
||||
while (len > 9L) { i++; len = len / 10; }
|
||||
return (i+1+len);
|
||||
}
|
||||
|
@ -376,9 +378,9 @@ int advancedLengthSimpleStringVerbatim(sexpSimpleString ss)
|
|||
*/
|
||||
void advancedPrintBase64SimpleString(sexpOutputStream os, sexpSimpleString ss)
|
||||
{
|
||||
long int len = simpleStringLength(ss);
|
||||
octet *c = simpleStringString(ss);
|
||||
long int i;
|
||||
octet * c = simpleStringString(ss);
|
||||
size_t len = simpleStringLength(ss);
|
||||
size_t i;
|
||||
|
||||
if (c == NULL)
|
||||
ErrorMessage(ERROR, "Can't print NULL string base 64");
|
||||
|
@ -398,9 +400,9 @@ void advancedPrintBase64SimpleString(sexpOutputStream os, sexpSimpleString ss)
|
|||
*/
|
||||
void advancedPrintHexSimpleString(sexpOutputStream os, sexpSimpleString ss)
|
||||
{
|
||||
long int len = simpleStringLength(ss);
|
||||
octet *c = simpleStringString(ss);
|
||||
long int i;
|
||||
octet * c = simpleStringString(ss);
|
||||
size_t len = simpleStringLength(ss);
|
||||
size_t i;
|
||||
|
||||
if (c == NULL)
|
||||
ErrorMessage(ERROR, "Can't print NULL string hexadecimal");
|
||||
|
@ -418,7 +420,7 @@ void advancedPrintHexSimpleString(sexpOutputStream os, sexpSimpleString ss)
|
|||
*/
|
||||
int advancedLengthSimpleStringHexadecimal(sexpSimpleString ss)
|
||||
{
|
||||
long int len = simpleStringLength(ss);
|
||||
size_t len = simpleStringLength(ss);
|
||||
|
||||
return (1+2*len+1);
|
||||
}
|
||||
|
@ -431,12 +433,14 @@ int advancedLengthSimpleStringHexadecimal(sexpSimpleString ss)
|
|||
*/
|
||||
int canPrintAsQuotedString(sexpSimpleString ss)
|
||||
{
|
||||
long int len = simpleStringLength(ss);
|
||||
octet *c = simpleStringString(ss);
|
||||
long int i;
|
||||
octet * c = simpleStringString(ss);
|
||||
size_t len = simpleStringLength(ss);
|
||||
size_t i;
|
||||
|
||||
if (c == NULL) return FALSE ;
|
||||
/*@-unsignedcompare@*/ /* XXX len now unsigned size_t. */
|
||||
if (len < 0) return FALSE;
|
||||
/*@=unsignedcompare@*/
|
||||
for (i=0; i<len; i++,c++) {
|
||||
if (!isTokenChar((int)(*c)) && *c != ' ')
|
||||
return FALSE;
|
||||
|
@ -452,9 +456,9 @@ int canPrintAsQuotedString(sexpSimpleString ss)
|
|||
*/
|
||||
void advancedPrintQuotedStringSimpleString(sexpOutputStream os, sexpSimpleString ss)
|
||||
{
|
||||
long int len = simpleStringLength(ss);
|
||||
octet *c = simpleStringString(ss);
|
||||
long int i;
|
||||
octet * c = simpleStringString(ss);
|
||||
size_t len = simpleStringLength(ss);
|
||||
size_t i;
|
||||
|
||||
os->putChar(os, '\"');
|
||||
for (i=0; i<len; i++) {
|
||||
|
@ -473,7 +477,8 @@ void advancedPrintQuotedStringSimpleString(sexpOutputStream os, sexpSimpleString
|
|||
*/
|
||||
int advancedLengthSimpleStringQuotedString(sexpSimpleString ss)
|
||||
{
|
||||
long int len = simpleStringLength(ss);
|
||||
size_t len = simpleStringLength(ss);
|
||||
|
||||
return (1+len+1);
|
||||
}
|
||||
|
||||
|
@ -484,7 +489,7 @@ int advancedLengthSimpleStringQuotedString(sexpSimpleString ss)
|
|||
*/
|
||||
void advancedPrintSimpleString(sexpOutputStream os, sexpSimpleString ss)
|
||||
{
|
||||
long int len = simpleStringLength(ss);
|
||||
size_t len = simpleStringLength(ss);
|
||||
|
||||
if (canPrintAsToken(os, ss))
|
||||
advancedPrintTokenSimpleString(os, ss);
|
||||
|
@ -528,9 +533,10 @@ int advancedLengthSimpleStringBase64(sexpSimpleString ss)
|
|||
/* advancedLengthSimpleString(os,ss)
|
||||
* Returns length of printed image of s
|
||||
*/
|
||||
int advancedLengthSimpleString(sexpOutputStream os, sexpSimpleString ss)
|
||||
size_t advancedLengthSimpleString(sexpOutputStream os, sexpSimpleString ss)
|
||||
{
|
||||
long int len = simpleStringLength(ss);
|
||||
size_t len = simpleStringLength(ss);
|
||||
|
||||
if (canPrintAsToken(os,ss))
|
||||
return advancedLengthSimpleStringToken(ss);
|
||||
else if (canPrintAsQuotedString(ss))
|
||||
|
@ -546,11 +552,11 @@ int advancedLengthSimpleString(sexpOutputStream os, sexpSimpleString ss)
|
|||
/* advancedLengthString(os,s)
|
||||
* Returns length of printed image of string s
|
||||
*/
|
||||
int advancedLengthString(sexpOutputStream os, sexpString s)
|
||||
size_t advancedLengthString(sexpOutputStream os, sexpString s)
|
||||
{
|
||||
sexpSimpleString ph = sexpStringPresentationHint(s);
|
||||
sexpSimpleString ss = sexpStringString(s);
|
||||
int len = 0;
|
||||
size_t len = 0;
|
||||
|
||||
if (ph != NULL)
|
||||
len += 2+advancedLengthSimpleString(os, ph);
|
||||
|
@ -562,11 +568,11 @@ int advancedLengthString(sexpOutputStream os, sexpString s)
|
|||
/* advancedLengthList(os,list)
|
||||
* Returns length of printed image of list given as iterator
|
||||
*/
|
||||
int advancedLengthList(sexpOutputStream os, sexpList list)
|
||||
size_t advancedLengthList(sexpOutputStream os, sexpList list)
|
||||
{
|
||||
sexpIter iter = sexpListIter(list);
|
||||
sexpObject object;
|
||||
int len = 1; /* for left paren */
|
||||
size_t len = 1; /* for left paren */
|
||||
|
||||
while (iter != NULL) {
|
||||
object = sexpIterObject(iter);
|
||||
|
|
|
@ -90,7 +90,7 @@ void * sexpAlloc(size_t n)
|
|||
sexpSimpleString newSimpleString(void)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies fileSystem @*/;
|
||||
long int simpleStringLength(sexpSimpleString ss)
|
||||
size_t simpleStringLength(sexpSimpleString ss)
|
||||
/*@*/;
|
||||
/*@exposed@*/ /*@null@*/
|
||||
octet *simpleStringString(sexpSimpleString ss)
|
||||
|
|
|
@ -0,0 +1,108 @@
|
|||
#include "system.h"
|
||||
|
||||
#include "base64.h"
|
||||
#include "mpbarrett.h"
|
||||
#include "mp.h"
|
||||
#include "popt.h"
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
const char * applechallenge = "09KF45soMYmvj6dpsUGiIg==";
|
||||
|
||||
#if 1
|
||||
const char * rsaaeskey = "\
|
||||
5QYIqmdZGTONY5SHjEJrqAhaa0W9wzDC5i6q221mdGZJ5ubO6Kg\
|
||||
yhC6U83wpY87TFdPRdfPQl2kVC7+Uefmx1bXdIUo07ZcJsqMbgtje4w2JQw0b\
|
||||
Uw2BlzNPmVGQOxfdpGc3LXZzNE0jI1D4conUEiW6rrzikXBhk7Y/i2naw13ayy\
|
||||
xaSwtkiJ0ltBQGYGErbV2tx43QSNj7O0JIG9GrF2GZZ6/UHo4VH+ZXgQ4NZvP/\
|
||||
QXPCsLutZsvusFDzIEq7TN1fveINOiwrzlN+bckEixvhXlvoQTWE2tjbmQYhMvO\
|
||||
FIly5gNbZiXi0l5AdolX4jDC2vndFHqWDks/3sPikNg==\
|
||||
";
|
||||
#else
|
||||
const char * rsaaeskey = "5QYIqmdZGTONY5SHjEJrqAhaa0W9wzDC5i6q221mdGZJ5ubO6KgyhC6U83wpY87TFdPRdfPQl2kVC7+Uefmx1bXdIUo07ZcJsqMbgtje4w2JQw0bUw2BlzNPmVGQOxfdpGc3LXZzNE0jI1D4conUEiW6rrzikXBhk7Y/i2naw13ayyxaSwtkiJ0ltBQGYGErbV2tx43QSNj7O0JIG9GrF2GZZ6/UHo4VH+ZXgQ4NZvP/QXPCsLutZsvusFDzIEq7TN1fveINOiwrzlN+bckEixvhXlvoQTWE2tjbmQYhMvOFIly5gNbZiXi0l5AdolX4jDC2vndFHqWDks/3sPikNg==";
|
||||
#endif
|
||||
|
||||
const char * aesiv = "zcZmAZtqh7uGcEwPXk0QeA==";
|
||||
|
||||
const char * appleresponse = "\
|
||||
u+msU8Cc7KBrVPjI/Ir8fOL8+C5D3Jsw1+acaW3MNTndrTQAeb/a\
|
||||
5m10UVBX6wb/DYQGY+b28ksSwBjN0nFOk4Y2cODEf83FAh7B\
|
||||
mkLpmpkpplp7zVXQ+Z9DcB6gC60ZsS3t98aoR7tSzVLKZNgi2X2sC+vGsz\
|
||||
utQxX03HK008VjcdngHv3g1p2knoETd07T6eVfZCmPqp6Ga7Dj8VIIj/GEP3\
|
||||
AjjDx3lJnQBXUDmxM484YXLXZjWFXCiY8GJt6whjf7/2c3rIoT3Z7PQpEvPmM\
|
||||
1MXU9cv4NL59Y/q0OAVQ38foOz7eGAhfvjOsCnHU25aik7/7ToIYt1tyVtap/kA==\
|
||||
";
|
||||
|
||||
/**
|
||||
* Convert to hex.
|
||||
* @param t target buffer (returned)
|
||||
* @param s source bytes
|
||||
* @param nbytes no. of bytes
|
||||
* @return target buffer
|
||||
*/
|
||||
/*@unused@*/ static inline
|
||||
char * pgpHexCvt(/*@returned@*/ char *t, const byte *s, int nbytes)
|
||||
/*@modifies *t @*/
|
||||
{
|
||||
static char hex[] = "0123456789abcdef";
|
||||
/*@-boundswrite@*/
|
||||
while (nbytes-- > 0) {
|
||||
unsigned int i;
|
||||
i = *s++;
|
||||
*t++ = hex[ (i >> 4) & 0xf ];
|
||||
*t++ = hex[ (i ) & 0xf ];
|
||||
}
|
||||
*t = '\0';
|
||||
/*@=boundswrite@*/
|
||||
return t;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return hex formatted representation of bytes.
|
||||
* @todo Remove static buffer.
|
||||
* @param p bytes
|
||||
* @param plen no. of bytes
|
||||
* @return hex formatted string
|
||||
*/
|
||||
/*@unused@*/ static inline /*@observer@*/
|
||||
char * pgpHexStr(const byte *p, unsigned int plen)
|
||||
/*@*/
|
||||
{
|
||||
static char prbuf[2048];
|
||||
char *t = prbuf;
|
||||
t = pgpHexCvt(t, p, plen);
|
||||
return prbuf;
|
||||
}
|
||||
|
||||
static int doit(const char * msg, const char * sig)
|
||||
{
|
||||
unsigned char * dec;
|
||||
size_t declen;
|
||||
int rc;
|
||||
|
||||
if ((rc = b64decode(sig, (void **)&dec, &declen)) != 0) {
|
||||
fprintf(stderr, "*** b64decode returns %d\n", rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
fprintf(stderr, "*** %p[%d] %s\n", dec, declen, msg);
|
||||
if (declen == 256) {
|
||||
fprintf(stderr, "%s\n", pgpHexStr(dec, declen/2));
|
||||
fprintf(stderr, "%s\n", pgpHexStr(dec+declen/2, declen/2));
|
||||
} else {
|
||||
fprintf(stderr, "%s\n", pgpHexStr(dec, declen));
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
|
||||
doit("applechallenge", applechallenge);
|
||||
doit("rsaaeskey", rsaaeskey);
|
||||
doit("aesiv", aesiv);
|
||||
doit("appleresponse", appleresponse);
|
||||
}
|
|
@ -103,11 +103,15 @@ int gnameToGid(const char * thisGname, gid_t * gid)
|
|||
if (grent == NULL) {
|
||||
/* XXX The filesystem package needs group/lock w/o getgrnam. */
|
||||
if (strcmp(thisGname, "lock") == 0) {
|
||||
/*@-boundswrite@*/
|
||||
*gid = lastGid = 54;
|
||||
/*@=boundswrite@*/
|
||||
return 0;
|
||||
} else
|
||||
if (strcmp(thisGname, "mail") == 0) {
|
||||
/*@-boundswrite@*/
|
||||
*gid = lastGid = 12;
|
||||
/*@=boundswrite@*/
|
||||
return 0;
|
||||
} else
|
||||
return -1;
|
||||
|
|
16
system.h
16
system.h
|
@ -561,16 +561,18 @@ typedef /*@concrete@*/ struct
|
|||
/*@=constuse@*/
|
||||
#endif
|
||||
|
||||
extern int glob (const char *pattern, int flags,
|
||||
int (*errfunc) (const char *, int),
|
||||
/*@out@*/ glob_t *pglob)
|
||||
/*@-type@*/ /* XXX glob64_t */
|
||||
extern int glob (const char *__pattern, int __flags,
|
||||
int (*__errfunc) (const char *, int),
|
||||
/*@out@*/ glob_t *__pglob)
|
||||
/*@globals errno, fileSystem @*/
|
||||
/*@modifies *pglob, errno, fileSystem @*/;
|
||||
/*@modifies *__pglob, errno, fileSystem @*/;
|
||||
/* XXX only annotation is a white lie */
|
||||
extern void globfree (/*@only@*/ glob_t *pglob)
|
||||
/*@modifies *pglob @*/;
|
||||
extern void globfree (/*@only@*/ glob_t *__pglob)
|
||||
/*@modifies *__pglob @*/;
|
||||
/*@=type@*/
|
||||
#ifdef _GNU_SOURCE
|
||||
extern int glob_pattern_p (const char *pattern, int quote)
|
||||
extern int glob_pattern_p (const char *__pattern, int __quote)
|
||||
/*@*/;
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue