[hackers] [sbase] crypt: free line and tiny cleanup || Hiltjo Posthuma

From: <git_AT_suckless.org>
Date: Sun, 23 Mar 2014 19:02:50 +0100

commit dd7eb6386917b64f331c94fab662829da56fab10
Author: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Sun Mar 23 13:45:52 2014 +0100

    crypt: free line and tiny cleanup
    
    Signed-off-by: Hiltjo Posthuma <hiltjo_AT_codemadness.org>

diff --git a/util/crypt.c b/util/crypt.c
index 7048659..2bca8fc 100644
--- a/util/crypt.c
+++ b/util/crypt.c
_AT_@ -39,14 +39,14 @@ cryptcheck(char *sumfile, int argc, char *argv[],
           struct crypt_ops *ops, uint8_t *md, size_t sz)
 {
         FILE *cfp, *fp;
- char *buf = NULL, *line, *file, *p;
+ char *line = NULL, *file, *p;
         int r, nonmatch = 0, formatsucks = 0, noread = 0, ret = EXIT_SUCCESS;
         size_t bufsiz = 0;
 
         if(!(cfp = fopen(sumfile, "r")))
                 eprintf("fopen %s:", sumfile);
 
- while((line = afgets(&buf, &bufsiz, cfp))) {
+ while(afgets(&line, &bufsiz, cfp)) {
                 if(!(file = strstr(line, " "))) {
                         formatsucks++;
                         continue;
_AT_@ -77,6 +77,7 @@ cryptcheck(char *sumfile, int argc, char *argv[],
                 fclose(fp);
         }
         fclose(cfp);
+ free(line);
         if(formatsucks > 0) {
                 weprintf("WARNING: %d lines are improperly formatted
", formatsucks);
                 ret = EXIT_FAILURE;
Received on Sun Mar 23 2014 - 19:02:50 CET

This archive was generated by hypermail 2.3.0 : Sun Mar 23 2014 - 19:12:24 CET