explicitly encode NULL strings in the cache
authorAndrew Tridgell <tridge@samba.org>
Mon, 10 Dec 2001 00:07:51 +0000 (00:07 +0000)
committerAndrew Tridgell <tridge@samba.org>
Mon, 10 Dec 2001 00:07:51 +0000 (00:07 +0000)
source/nsswitch/winbindd_cache.c

index 4221e26ee1abd21b05aec7f4923b85721fa9fce1..e78410e3a50a710ac7bfdd0a1be43b0fa12594bd 100644 (file)
@@ -119,6 +119,12 @@ static char *centry_string(struct cache_entry *centry, TALLOC_CTX *mem_ctx)
        char *ret;
 
        len = centry_uint32(centry);
+
+       if (len == 0xFFFF) {
+               /* a deliberate NULL string */
+               return NULL;
+       }
+
        if (centry->len - centry->ofs < len) {
                DEBUG(0,("centry corruption? needed %d bytes, have %d\n", 
                         len, centry->len - centry->ofs));
@@ -267,7 +273,15 @@ static void centry_put_uint32(struct cache_entry *centry, uint32 v)
  */
 static void centry_put_string(struct cache_entry *centry, const char *s)
 {
-       int len = strlen(s);
+       int len;
+
+       if (!s) {
+               /* null strings are marked as len 0xFFFF */
+               centry_put_uint32(centry, 0xFFFF);
+               return;
+       }
+
+       len = strlen(s);
        centry_put_uint32(centry, len);
        centry_expand(centry, len);
        memcpy(centry->data + centry->ofs, s, len);