Change usage of assert to log a critical error before actually asserting,
so that we can tell this has happened from the logfile.
12 files changed:
* Copyright 2002 Project Purple
*/
* Copyright 2002 Project Purple
*/
#include <stdlib.h>
#include "armor.h"
#include "keystructs.h"
#include <stdlib.h>
#include "armor.h"
#include "keystructs.h"
#include "onak-conf.h"
#include "parsekey.h"
#include "onak-conf.h"
#include "parsekey.h"
} else if (c == 63) {
c = '/';
} else {
} else if (c == 63) {
c = '/';
} else {
+ log_assert(ctx != NULL);
state = (struct armor_context *) ctx;
switch (state->curoctet++) {
state = (struct armor_context *) ctx;
switch (state->curoctet++) {
unsigned char tmpc;
int i;
unsigned char tmpc;
int i;
+ log_assert(ctx != NULL);
state = (struct dearmor_context *) ctx;
*c = 0;
state = (struct dearmor_context *) ctx;
*c = 0;
* Copyright 2004 Project Purple
*/
* Copyright 2004 Project Purple
*/
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
struct openpgp_signedpacket_list *tmp = NULL;
int merged = 0;
struct openpgp_signedpacket_list *tmp = NULL;
int merged = 0;
+ log_assert(key != NULL);
curuid = key->uids;
while (curuid != NULL) {
dup = find_signed_packet(curuid->next, curuid->packet);
curuid = key->uids;
while (curuid != NULL) {
dup = find_signed_packet(curuid->next, curuid->packet);
while (tmp != NULL && tmp->next != dup) {
tmp = tmp->next;
}
while (tmp != NULL && tmp->next != dup) {
tmp = tmp->next;
}
+ log_assert(tmp != NULL);
tmp->next = dup->next;
dup->next = NULL;
free_signedpacket_list(dup);
tmp->next = dup->next;
dup->next = NULL;
free_signedpacket_list(dup);
* Copyright 2002 Project Purple
*/
* Copyright 2002 Project Purple
*/
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
int length = 0;
int packetlen = 0;
int length = 0;
int packetlen = 0;
+ log_assert(data != NULL);
length = (data[0] << 8) + data[1] + 2;
length = (data[0] << 8) + data[1] + 2;
* Copyright 2002-2004 Project Purple
*/
* Copyright 2002-2004 Project Purple
*/
#include <sys/types.h>
#include <sys/uio.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <ctype.h>
- assert(dbenv != NULL);
- assert(txn == NULL);
+ log_assert(dbenv != NULL);
+ log_assert(txn == NULL);
ret = dbenv->txn_begin(dbenv,
NULL, /* No parent transaction */
ret = dbenv->txn_begin(dbenv,
NULL, /* No parent transaction */
- assert(dbenv != NULL);
- assert(txn != NULL);
+ log_assert(dbenv != NULL);
+ log_assert(txn != NULL);
ret = txn->commit(txn,
0);
ret = txn->commit(txn,
0);
#include "keyid.h"
#include "keystructs.h"
#include "log.h"
#include "keyid.h"
#include "keystructs.h"
#include "log.h"
unsigned char c;
size_t modlen, explen;
unsigned char c;
size_t modlen, explen;
- assert(fingerprint != NULL);
- assert(len != NULL);
+ log_assert(fingerprint != NULL);
+ log_assert(len != NULL);
size_t length = 0;
unsigned char buff[20];
size_t length = 0;
unsigned char buff[20];
- assert(packet != NULL);
+ log_assert(packet != NULL);
switch (packet->data[0]) {
case 2:
switch (packet->data[0]) {
case 2:
* Copyright 2002 Project Purple
*/
* Copyright 2002 Project Purple
*/
#include <inttypes.h>
#include <stdbool.h>
#include <stdio.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdio.h>
* Copyright 2000-2002 Project Purple
*/
* Copyright 2000-2002 Project Purple
*/
#include <stdio.h>
#include <stdlib.h>
#include "ll.h"
#include <stdio.h>
#include <stdlib.h>
#include "ll.h"
struct ll *lladd(struct ll *curll, void *object)
{
struct ll *lladd(struct ll *curll, void *object)
{
struct ll *cur = NULL;
struct ll *old = NULL;
struct ll *cur = NULL;
struct ll *old = NULL;
- assert(objectcmp != NULL);
+ log_assert(objectcmp != NULL);
cur = curll;
if (cur == NULL) {
cur = curll;
if (cur == NULL) {
- assert(objectcmp != NULL);
+ log_assert(objectcmp != NULL);
cur = curll;
while (cur != NULL && (*objectcmp)(cur->object, object)) {
cur = curll;
while (cur != NULL && (*objectcmp)(cur->object, object)) {
#ifndef __LOG_H__
#define __LOG_H__
#ifndef __LOG_H__
#define __LOG_H__
+#include <assert.h>
+
+#define log_assert(expr) \
+ if (!(expr)) { \
+ logthing(LOGTHING_CRITICAL, \
+ "Assertion %s failed in %s, line %d", \
+ #expr, \
+ __FILE__, \
+ __LINE__); \
+ } \
+ assert(expr)
+
/*
* loglevels - levels of severity for a log entry
*
/*
* loglevels - levels of severity for a log entry
*
* Copyright 2002 Project Purple
*/
* Copyright 2002 Project Purple
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "keystructs.h"
#include "ll.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "keystructs.h"
#include "ll.h"
{
struct openpgp_packet *newpacket = NULL;
{
struct openpgp_packet *newpacket = NULL;
- assert(packet != NULL);
+ log_assert(packet != NULL);
newpacket = malloc(sizeof (struct openpgp_packet));
if (newpacket != NULL) {
newpacket = malloc(sizeof (struct openpgp_packet));
if (newpacket != NULL) {
struct openpgp_packet_list **list_end,
struct openpgp_packet_list *packet_list)
{
struct openpgp_packet_list **list_end,
struct openpgp_packet_list *packet_list)
{
- assert(list != NULL);
- assert(list_end != NULL);
+ log_assert(list != NULL);
+ log_assert(list_end != NULL);
for (; packet_list != NULL; packet_list = packet_list->next) {
ADD_PACKET_TO_LIST((*list_end),
for (; packet_list != NULL; packet_list = packet_list->next) {
ADD_PACKET_TO_LIST((*list_end),
* including the data part.
*/
void free_packet(struct openpgp_packet *packet) {
* including the data part.
*/
void free_packet(struct openpgp_packet *packet) {
- assert(packet != NULL);
+ log_assert(packet != NULL);
if (packet->data != NULL) {
free(packet->data);
if (packet->data != NULL) {
free(packet->data);
void free_packet_list(struct openpgp_packet_list *packet_list) {
struct openpgp_packet_list *nextpacket = NULL;
void free_packet_list(struct openpgp_packet_list *packet_list) {
struct openpgp_packet_list *nextpacket = NULL;
- assert(packet_list != NULL);
+ log_assert(packet_list != NULL);
while (packet_list != NULL) {
nextpacket = packet_list->next;
while (packet_list != NULL) {
nextpacket = packet_list->next;
struct openpgp_signedpacket_list *signedpacket_list) {
struct openpgp_signedpacket_list *nextpacket = NULL;
struct openpgp_signedpacket_list *signedpacket_list) {
struct openpgp_signedpacket_list *nextpacket = NULL;
- assert(signedpacket_list != NULL);
+ log_assert(signedpacket_list != NULL);
while (signedpacket_list != NULL) {
nextpacket = signedpacket_list->next;
while (signedpacket_list != NULL) {
nextpacket = signedpacket_list->next;
void free_publickey(struct openpgp_publickey *key) {
struct openpgp_publickey *nextkey = NULL;
void free_publickey(struct openpgp_publickey *key) {
struct openpgp_publickey *nextkey = NULL;
+ log_assert(key != NULL);
while (key != NULL) {
nextkey = key->next;
while (key != NULL) {
nextkey = key->next;
* Copyright 2002 Project Purple
*/
* Copyright 2002 Project Purple
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct openpgp_packet_list *curpacket = NULL;
struct openpgp_packet_list *nextpacket = NULL;
struct openpgp_packet_list *curpacket = NULL;
struct openpgp_packet_list *nextpacket = NULL;
- assert(compare_packets(old->packet, new->packet));
+ log_assert(compare_packets(old->packet, new->packet));
curpacket = new->sigs;
while (curpacket != NULL) {
curpacket = new->sigs;
while (curpacket != NULL) {
if (lastpacket != NULL) {
lastpacket->next = curpacket->next;
} else {
if (lastpacket != NULL) {
lastpacket->next = curpacket->next;
} else {
- assert(curpacket == new->sigs);
+ log_assert(curpacket == new->sigs);
new->sigs = curpacket->next;
}
curpacket->next = NULL;
new->sigs = curpacket->next;
}
curpacket->next = NULL;
if (lastpacket != NULL) {
lastpacket->next = curpacket->next;
} else {
if (lastpacket != NULL) {
lastpacket->next = curpacket->next;
} else {
- assert(curpacket == b->revocations);
+ log_assert(curpacket == b->revocations);
b->revocations = curpacket->next;
}
curpacket->next = NULL;
b->revocations = curpacket->next;
}
curpacket->next = NULL;
* Copyright 2002 Project Purple
*/
* Copyright 2002 Project Purple
*/
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
* key (it should be a revocation), to the current UID
* or the current subkey.
*/
* key (it should be a revocation), to the current UID
* or the current subkey.
*/
- assert(curkey != NULL);
+ log_assert(curkey != NULL);
if (curkey->subkeys != NULL) {
ADD_PACKET_TO_LIST_END(curkey->last_subkey,
sig,
if (curkey->subkeys != NULL) {
ADD_PACKET_TO_LIST_END(curkey->last_subkey,
sig,
/*
* It's a UID packet (or a photo id, which is similar).
*/
/*
* It's a UID packet (or a photo id, which is similar).
*/
- assert(curkey != NULL);
- assert(curkey->subkeys == NULL);
+ log_assert(curkey != NULL);
+ log_assert(curkey->subkeys == NULL);
ADD_PACKET_TO_LIST_END(curkey,
uid,
packet_dup(packets->packet));
ADD_PACKET_TO_LIST_END(curkey,
uid,
packet_dup(packets->packet));
/*
* It's a subkey packet.
*/
/*
* It's a subkey packet.
*/
- assert(curkey != NULL);
+ log_assert(curkey != NULL);
ADD_PACKET_TO_LIST_END(curkey,
subkey,
packet_dup(packets->packet));
ADD_PACKET_TO_LIST_END(curkey,
subkey,
packet_dup(packets->packet));
int keys = 0;
bool inpacket = false;
int keys = 0;
bool inpacket = false;
- assert(packets != NULL);
+ log_assert(packets != NULL);
curpacket = *packets;
if (curpacket != NULL) {
while (curpacket->next != NULL) {
curpacket = *packets;
if (curpacket != NULL) {
while (curpacket->next != NULL) {
* Copyright 2004 Project Purple
*/
* Copyright 2004 Project Purple
*/
#include <inttypes.h>
#include <stdbool.h>
#include <stdio.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdio.h>
- assert(key != NULL);
- assert(photo != NULL);
- assert(length != NULL);
+ log_assert(key != NULL);
+ log_assert(photo != NULL);
+ log_assert(length != NULL);