-LRN: initialize rd to avoid having garbage in flags
[oweals/gnunet.git] / src / namestore / namestore_api.c
index d699c6ee34467f8b18b873fb4647340a303279cd..4c056c82b2774097045c67899b2c6148de526071 100644 (file)
 
 #define LOG(kind,...) GNUNET_log_from (kind, "gns-api",__VA_ARGS__)
 
-/**
- * Maximum length of any name, including 0-termination.
- */
-#define MAX_NAME_LEN 256
-
 
 /**
  * An QueueEntry used to store information for a pending
@@ -395,48 +390,48 @@ handle_record_remove_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
                               const struct RecordRemoveResponseMessage* msg,
                               size_t size)
 {
-  int res;
   int ret;
   const char *emsg;
 
   /* Operation done, remove */
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Received `%s'\n",
        "RECORD_REMOVE_RESPONSE");
-  /*
-   *  results:
-   *  0 : successful
-   *  1 : No records for entry
-   *  2 : Could not find record to remove
-   *  3 : Failed to create new signature
-   *  4 : Failed to put new set of records in database
-   */
-  res = ntohl (msg->op_result);
-  switch (res) 
+  switch (ntohl (msg->op_result)) 
   {
-  case 0:
+  case RECORD_REMOVE_RESULT_SUCCESS:
     ret = GNUNET_OK;
     emsg = NULL;
     break;
-  case 1:
+  case RECORD_REMOVE_RESULT_NO_RECORDS:
     ret = GNUNET_NO;
     emsg = NULL;
     break;
-  case 2:
+  case RECORD_REMOVE_RESULT_RECORD_NOT_FOUND:
     ret = GNUNET_NO;
     emsg = NULL;
     break;
-  case 3:
+  case RECORD_REMOVE_RESULT_FAILED_TO_SIGN:
     ret = GNUNET_SYSERR;
     emsg = _("Failed to create new signature");
     break;
-  case 4:
+  case RECORD_REMOVE_RESULT_FAILED_TO_PUT_UPDATE:
     ret = GNUNET_SYSERR;
     emsg = _("Failed to put new set of records in database");
     break;
+  case RECORD_REMOVE_RESULT_FAILED_TO_REMOVE:
+    ret = GNUNET_SYSERR;
+    emsg = _("Failed to remove records from database");
+    break;
+  case RECORD_REMOVE_RESULT_FAILED_ACCESS_DATABASE:
+    ret = GNUNET_SYSERR;
+    emsg = _("Failed to access database");
+    break;
+  case RECORD_REMOVE_RESULT_FAILED_INTERNAL_ERROR:
+    ret = GNUNET_SYSERR;
+    emsg = _("unknown internal error in namestore");
+    break;
   default:
     GNUNET_break (0);
-    ret = GNUNET_SYSERR;
-    emsg = _("Protocol error");
     if (NULL != qe->cont)      
       qe->cont (qe->cont_cls, GNUNET_SYSERR, _("Protocol error"));
     return GNUNET_NO;
@@ -1122,7 +1117,7 @@ GNUNET_NAMESTORE_verify_signature (const struct GNUNET_CRYPTO_RsaPublicKeyBinary
   rd_ser_len = GNUNET_NAMESTORE_records_get_size (rd_count, rd);
   sig_len = sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + sizeof (struct GNUNET_TIME_AbsoluteNBO) + rd_ser_len + name_len;
   {
-    char sig_buf[rd_ser_len] GNUNET_ALIGN;
+    char sig_buf[sig_len] GNUNET_ALIGN;
 
     sig_purpose = (struct GNUNET_CRYPTO_RsaSignaturePurpose *) sig_buf;
     sig_purpose->size = htonl (sig_len);