diff cinst/main.c @ 91:80ab2168760f

Also add output size handling to str_append_str
author Andre Heinecke <aheinecke@intevation.de>
date Fri, 21 Mar 2014 09:47:05 +0000
parents 899fcddb92d0
children c602d8cfa619
line wrap: on
line diff
--- a/cinst/main.c	Fri Mar 21 09:45:54 2014 +0000
+++ b/cinst/main.c	Fri Mar 21 09:47:05 2014 +0000
@@ -60,6 +60,7 @@
 {
     int lines_read = 0;
     int readingList = 0;
+    size_t list_size = 0;
     char buf[MAX_LINE_LENGTH + 1];
 
     if (*certificate_list || *to_install || *to_remove) {
@@ -69,6 +70,10 @@
 
     while (fgets(buf, MAX_LINE_LENGTH + 1, stdin)) {
         size_t len = strlen(buf); /* fgets ensures buf is terminated */
+        if (len < 2) {
+            printf("Line to short.\n");
+            return ERR_INVALID_INPUT;
+        }
         if (lines_read ++ > MAX_LINES) {
             printf("Too many lines\n");
             return ERR_TOO_MUCH_INPUT;
@@ -82,7 +87,7 @@
             continue;
         }
         if (readingList) {
-            str_append_str(certificate_list, buf, len);
+            str_append_str(certificate_list, &list_size, buf, len);
             continue;
         }
         if (*buf == 'I') {

http://wald.intevation.org/projects/trustbridge/