=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/htpasswd/htpasswd.c,v retrieving revision 1.3 retrieving revision 1.4 diff -c -r1.3 -r1.4 *** src/usr.bin/htpasswd/htpasswd.c 2014/03/17 13:54:58 1.3 --- src/usr.bin/htpasswd/htpasswd.c 2014/03/17 21:25:09 1.4 *************** *** 1,4 **** ! /* $OpenBSD: htpasswd.c,v 1.3 2014/03/17 13:54:58 florian Exp $ */ /* * Copyright (c) 2014 Florian Obser * --- 1,4 ---- ! /* $OpenBSD: htpasswd.c,v 1.4 2014/03/17 21:25:09 benno Exp $ */ /* * Copyright (c) 2014 Florian Obser * *************** *** 106,112 **** " reading or writing"); umask(old_umask); } else ! err(1, "cannot open password file for reading"); } /* file already exits, copy content and filter login out */ if (out == NULL) { --- 106,113 ---- " reading or writing"); umask(old_umask); } else ! err(1, "cannot open password file for" ! " reading or writing"); } /* file already exits, copy content and filter login out */ if (out == NULL) { *************** *** 134,143 **** if (in != NULL) { if (fseek(in, 0, SEEK_SET) == -1) err(1, "cannot seek in password file"); - if (ftruncate(fileno(in), 0) == -1) - err(1, "cannot truncate password file"); if (fseek(out, 0, SEEK_SET) == -1) err(1, "cannot seek in temp file"); while ((linelen = getline(&line, &linesize, out)) != -1) if (fprintf(in, "%s", line) == -1) --- 135,144 ---- if (in != NULL) { if (fseek(in, 0, SEEK_SET) == -1) err(1, "cannot seek in password file"); if (fseek(out, 0, SEEK_SET) == -1) err(1, "cannot seek in temp file"); + if (ftruncate(fileno(in), 0) == -1) + err(1, "cannot truncate password file"); while ((linelen = getline(&line, &linesize, out)) != -1) if (fprintf(in, "%s", line) == -1)