Ver código fonte

fix tv_gen.c for scan-build run

Steffen Jaeckel 8 anos atrás
pai
commit
18ba0cbda9
1 arquivos alterados com 22 adições e 2 exclusões
  1. 22 2
      demos/tv_gen.c

+ 22 - 2
demos/tv_gen.c

@@ -213,7 +213,11 @@ void omac_gen(void)
          }
          len = sizeof(output);
          if ((err = omac_memory(x, key, kl, input, y, output, &len)) != CRYPT_OK) {
-            printf("Error omacing: %s\n", error_to_string(err));
+            printf("Error OMAC'ing: %s\n", error_to_string(err));
+            exit(EXIT_FAILURE);
+         }
+         if (len == 0) {
+            printf("Error OMAC'ing: zero length\n");
             exit(EXIT_FAILURE);
          }
          fprintf(out, "%3d: ", y);
@@ -270,7 +274,11 @@ void pmac_gen(void)
          }
          len = sizeof(output);
          if ((err = pmac_memory(x, key, kl, input, y, output, &len)) != CRYPT_OK) {
-            printf("Error omacing: %s\n", error_to_string(err));
+            printf("Error PMACing: %s\n", error_to_string(err));
+            exit(EXIT_FAILURE);
+         }
+         if (len == 0) {
+            printf("Error PMAC'ing: zero length\n");
             exit(EXIT_FAILURE);
          }
          fprintf(out, "%3d: ", y);
@@ -331,6 +339,10 @@ void eax_gen(void)
             printf("Error EAX'ing: %s\n", error_to_string(err));
             exit(EXIT_FAILURE);
          }
+         if (len == 0) {
+            printf("Error EAX'ing: zero length\n");
+            exit(EXIT_FAILURE);
+         }
          fprintf(out, "%3d: ", y1);
          for (z = 0; z < y1; z++) {
             fprintf(out, "%02X", plaintext[z]);
@@ -396,6 +408,10 @@ void ocb_gen(void)
             printf("Error OCB'ing: %s\n", error_to_string(err));
             exit(EXIT_FAILURE);
          }
+         if (len == 0) {
+            printf("Error OCB'ing: zero length\n");
+            exit(EXIT_FAILURE);
+         }
          fprintf(out, "%3d: ", y1);
          for (z = 0; z < y1; z++) {
             fprintf(out, "%02X", plaintext[z]);
@@ -462,6 +478,10 @@ void ocb3_gen(void)
             printf("Error OCB3'ing: %s\n", error_to_string(err));
             exit(EXIT_FAILURE);
          }
+         if (len == 0) {
+            printf("Error OCB3'ing: zero length\n");
+            exit(EXIT_FAILURE);
+         }
          fprintf(out, "%3d: ", y1);
          for (z = 0; z < y1; z++) {
             fprintf(out, "%02X", plaintext[z]);