summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@dside.dyndns.org>2005-07-14 19:39:08 +0000
committerSuren A. Chilingaryan <csa@dside.dyndns.org>2005-07-14 19:39:08 +0000
commit7a6b6a56dabe1e62a0fbc6222c090aa077bcadc7 (patch)
tree1b509a460c238dc6a69c82930a9f726ee0a969e0 /src
parent3e5322512be81527430059b901747df7692a6855 (diff)
downloadlibrcc-7a6b6a56dabe1e62a0fbc6222c090aa077bcadc7.tar.gz
librcc-7a6b6a56dabe1e62a0fbc6222c090aa077bcadc7.tar.bz2
librcc-7a6b6a56dabe1e62a0fbc6222c090aa077bcadc7.tar.xz
librcc-7a6b6a56dabe1e62a0fbc6222c090aa077bcadc7.zip
Example
Diffstat (limited to 'src')
-rw-r--r--src/internal.h1
-rw-r--r--src/rccdb4.c5
-rw-r--r--src/rcclocale.c2
-rw-r--r--src/rccstring.c3
4 files changed, 6 insertions, 5 deletions
diff --git a/src/internal.h b/src/internal.h
index 83a8028..1d3a532 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -18,6 +18,7 @@
#define RCC_MAX_PLUGINS 32
#define RCC_MAX_STRING_CHARS 1024
#define RCC_MAX_PREFIX_CHARS 32
+#define RCC_MIN_DB4_CHARS 3
struct rcc_context_t {
char locale_variable[RCC_MAX_VARIABLE_CHARS+1];
diff --git a/src/rccdb4.c b/src/rccdb4.c
index 5e0894a..fc821a8 100644
--- a/src/rccdb4.c
+++ b/src/rccdb4.c
@@ -4,7 +4,6 @@
#include "rccdb4.h"
#define DATABASE "autolearn.db"
-#define MIN_CHARS 3
int rccInitDb4(rcc_context ctx, const char *name, rcc_db4_flags flags) {
size_t size;
@@ -98,7 +97,7 @@ int rccDb4SetKey(db4_context ctx, const char *orig, size_t olen, const rcc_strin
data.data = (char*)string;
data.size = strlen(string)+1;
- if (key.size < MIN_CHARS) return -1;
+ if (key.size < RCC_MIN_DB4_CHARS) return -1;
err = ctx->db->put(ctx->db, NULL, &key, &data, 0);
return err;
@@ -117,6 +116,8 @@ rcc_string rccDb4GetKey(db4_context ctx, const char *orig, size_t olen) {
key.size = STRNLEN(orig, olen); /* No ending zero */
data.flags = DB_DBT_REALLOC;
+
+ if (key.size < RCC_MIN_DB4_CHARS) return NULL;
err = ctx->db->get(ctx->db, NULL, &key, &data, 0);
if (err) return NULL;
diff --git a/src/rcclocale.c b/src/rcclocale.c
index 9095bca..7bfa54b 100644
--- a/src/rcclocale.c
+++ b/src/rcclocale.c
@@ -46,7 +46,7 @@ int rccLocaleGetLanguage(char *result, const char *lv, unsigned int n) {
else if (!strcasecmp(lv, "LANGUAGE")) l = getenv("LANGUAGE");
else l = NULL;
}
- if ((!l)||(strcmp(l,"C")==0)||(strcmp(l,"POSIX")==0)) return -1;
+ if ((!l)||(!strcmp(l,"C"))||(!strcmp(l,"POSIX"))) return -1;
for (i=0;((l[i])&&(l[i]!='.')&&(l[i]!=':'));i++);
diff --git a/src/rccstring.c b/src/rccstring.c
index d520693..bd5ef15 100644
--- a/src/rccstring.c
+++ b/src/rccstring.c
@@ -80,10 +80,9 @@ size_t rccStringSizedCheck(const char *str, size_t len) {
newlen = STRNLEN(str, len);
if (newlen>sizeof(rcc_string_header)) {
- if ((len==newlen)&&(str[newlen-1])) return 0;
+ if ((len==newlen)&&(!str[newlen-2])) return 0;
newlen-=sizeof(rcc_string_header);
} else return 0;
-
if (((rcc_string_header*)str)->magic == RCC_STRING_MAGIC) return newlen;
return 0;
}