~ubuntu-branches/ubuntu/wily/grub2/wily-proposed

« back to all changes in this revision

Viewing changes to util/grub-mkpasswd-pbkdf2.c

  • Committer: Bazaar Package Importer
  • Author(s): Felix Zielcke, Robert Millan, Felix Zielcke
  • Date: 2010-01-26 19:26:25 UTC
  • mfrom: (1.13.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20100126192625-coq6czap2ofjollf
Tags: 1.98~20100126-1
* New Bazaar snapshot.
  - Includes mipsel-yeeloong port.

[ Robert Millan ]
* config.in: Lower priority of grub2/linux_cmdline_default.

[ Felix Zielcke ]
* Drop `CFLAGS=-O0' workaround on powerpc. Should be fixed correctly now.
* Ship grub-bin2h and grub-script-check in grub-common.
* Terminate NEWS.Debian with a blank line like lintian would suggest
  if that check would be working correctly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
}
51
51
 
52
52
int 
53
 
grub_vsprintf (char *str, const char *fmt, va_list args)
 
53
grub_vsnprintf (char *str, grub_size_t n, const char *fmt, va_list args)
54
54
{
55
 
  return vsprintf (str, fmt, args);
 
55
  return vsnprintf (str, n, fmt, args);
56
56
}
57
57
 
58
58
void
74
74
usage (int status)
75
75
{
76
76
  if (status)
77
 
    fprintf (stderr, "Try ``grub-scrypt --help'' for more information.\n");
 
77
    fprintf (stderr, "Try `%s --help' for more information.\n", program_name);
78
78
  else
79
79
    printf ("\
80
 
Usage: grub-scrypt [OPTIONS]\n\
 
80
Usage: %s [OPTIONS]\n\
81
81
\nOptions:\n\
82
82
     -c number, --iteration-count=number  Number of PBKDF2 iterations\n\
83
83
     -l number, --buflen=number           Length of generated hash\n\
84
84
     -s number, --salt=number             Length of salt\n\
85
85
\n\
86
 
Report bugs to <%s>.\n", PACKAGE_BUGREPORT);
 
86
Report bugs to <%s>.\n", program_name, PACKAGE_BUGREPORT);
87
87
 
88
88
  exit (status);
89
89
}
165
165
 
166
166
  bufhex = malloc (buflen * 2 + 1);
167
167
  if (!bufhex)
168
 
    grub_util_error ("Out of memory");
 
168
    grub_util_error ("out of memory");
169
169
  buf = malloc (buflen);
170
170
  if (!buf)
171
171
    {
172
172
      free (bufhex);
173
 
      grub_util_error ("Out of memory");
 
173
      grub_util_error ("out of memory");
174
174
    }
175
175
 
176
176
  salt = malloc (saltlen);
178
178
    {
179
179
      free (bufhex);
180
180
      free (buf);
181
 
      grub_util_error ("Out of memory");
 
181
      grub_util_error ("out of memory");
182
182
    }
183
183
  salthex = malloc (saltlen * 2 + 1);
184
184
  if (!salthex)
186
186
      free (salt);
187
187
      free (bufhex);
188
188
      free (buf);
189
 
      grub_util_error ("Out of memory");
 
189
      grub_util_error ("out of memory");
190
190
    }
191
191
 
192
192
  /* Disable echoing. Based on glibc.  */
225
225
      /* Restore the original setting.  */
226
226
      if (tty_changed)
227
227
        (void) tcsetattr (fileno (in), TCSAFLUSH, &s);
228
 
      grub_util_error ("Failure to read password");
 
228
      grub_util_error ("failure to read password");
229
229
    }
230
230
  if (nr >= 1 && pass1[nr-1] == '\n')
231
231
    pass1[nr-1] = 0;
249
249
      free (bufhex);
250
250
      free (salthex);
251
251
      free (salt);
252
 
      grub_util_error ("Failure to read password");
 
252
      grub_util_error ("failure to read password");
253
253
    }
254
254
  if (nr >= 1 && pass2[nr-1] == '\n')
255
255
    pass2[nr-1] = 0;
264
264
      free (bufhex);
265
265
      free (salthex);
266
266
      free (salt);
267
 
      grub_util_error ("Passwords don't match");
 
267
      grub_util_error ("passwords don't match");
268
268
    }
269
269
  memset (pass2, 0, strlen (pass2));
270
270
  free (pass2);
286
286
        free (salthex);
287
287
        free (salt);
288
288
        fclose (f);
289
 
        grub_util_error ("Couldn't retrieve random data for salt");
 
289
        grub_util_error ("couldn't retrieve random data for salt");
290
290
      }
291
291
    rd = fread (salt, 1, saltlen, f);
292
292
    if (rd != saltlen)
299
299
        free (salthex);
300
300
        free (salt);
301
301
        fclose (f);
302
 
        grub_util_error ("Couldn't retrieve random data for salt");
 
302
        grub_util_error ("couldn't retrieve random data for salt");
303
303
      }
304
304
    fclose (f);
305
305
  }
321
321
      memset (salthex, 0, 2 * saltlen);
322
322
      free (salt);
323
323
      free (salthex);
324
 
      grub_util_error ("Cryptographic error number %d", gcry_err);
 
324
      grub_util_error ("cryptographic error number %d", gcry_err);
325
325
    }
326
326
 
327
327
  hexify (bufhex, buf, buflen);