Re: httpd patterns double free

2016-02-14 Thread Alexander Schrijver
On Sun, Feb 14, 2016 at 12:20:53PM +0100, Martin Natano wrote:
> Are you sure the issue you ran into is caused by server_close_http()
> being called twice? The only caller thereof is server_free(), which also
> frees the client struct. This would result in use after free in
> server_close_http() even before the str_match_free() call. I would
> rather guess that the sequence in question is server_close_http() being
> called after server_reset_http().
> 
> However, your patch looks good to me.
> 
> natano

I am sorry, you are right, it was not server_close_http being called twice.
Instead, it was server_reset_http being called twice.

This is the log where I added a printf to server_reset_http and
server_close_http which print the function name and the struct client *clt.

/usr/src/usr.sbin/httpd $ sudo ./httpd -d -vvv 
startup
server_privinit: adding server default
socket_rlimit: max open files 1024
socket_rlimit: max open files 1024
server_launch: running server default
server_launch: running server default
server_reset_http 1211d800
server_reset_http 1211d800
default 192.168.1.204 - - [14/Feb/2016:15:47:40 +0100] "GET /~alex/ HTTP/1.1" 
200 231
httpd(6456) in free(): error: chunk is already free 0x63512118820
logger exiting, pid 18387
server exiting, pid 5809
parent terminating, pid 4688



httpd patterns double free

2016-02-11 Thread Alexander Schrijver
I ran into this issue when setting up my public_html folder using this 
configuration.

prefork 2

server "default" {
   listen on * port 80

   location match "/~*" {
  root "/users"
   }
}

types {
   text/csscss
   text/html   html htm
   text/txttxt
   image/gif   gif
   image/jpeg  jpeg jpg
   image/png   png
   application/javascript  js
   application/xml xml
}

The patch below fixed it for me. (server_close_http calls str_match_free and
server_close_http can be called more than once.)

Index: patterns.c
===
RCS file: /backup/mirrors/cvsync/src/usr.sbin/httpd/patterns.c,v
retrieving revision 1.4
diff -u -p -u -r1.4 patterns.c
--- patterns.c  18 Aug 2015 08:26:39 -  1.4
+++ patterns.c  11 Feb 2016 14:45:55 -
@@ -708,5 +708,6 @@ str_match_free(struct str_match *m)
for (i = 0; i < m->sm_nmatch; i++)
free(m->sm_match[i]);
free(m->sm_match);
+   m->sm_match = NULL;
m->sm_nmatch = 0;
 }



Re: sed -i

2015-07-17 Thread Alexander Schrijver
On Fri, Jul 17, 2015 at 06:10:46PM +0200, Jasper Lievisse Adriaanse wrote:
 Here's a diff to add the '-i' flag to sed to do inplace edits. It's mostly
 from FreeBSD with some adjustments to prevent a race with unlink() and fopen()
 during the tempfile creation.

\o/



libssl code disabled since 1998

2014-05-29 Thread Alexander Schrijver
The diff below removes code which has been disabled since 1998 or maybe even
before.

https://github.com/openssl/openssl/blame/master/ssl/ssl.h#L1758-L1764

There is a lot of interesting backwards compatibility stuff before and after
this piece of code. I have a diff for the SSL_(set|get)_(time|timeout) stuff.

The SSL_get_cipher_* defines seem to be actually used quite a bit according to 
github.

https://github.com/search?q=SSL_get_cipher+extension%3Ac+language%3Actype=Coderef=searchresults
https://github.com/search?q=SSL_get_cipher_bits+extension%3Ac+language%3Actype=Coderef=searchresults
https://github.com/search?q=SSL_get_cipher_version+extension%3Ac+language%3Actype=Coderef=searchresults
https://github.com/search?q=SSL_get_cipher_name+extension%3Ac+language%3Actype=Coderef=searchresults

OpenSSL_add_ssl_algorithms and SSLeay_add_ssl_algorithms too:

https://github.com/search?q=OpenSSL_add_ssl_algorithms+extension%3Ac+language%3Actype=Coderef=searchresults
https://github.com/search?q=SSLeay_add_ssl_algorithms+extension%3Ac+language%3Actype=Coderef=searchresults

I don't know how github results translates into the actually usage in the
OpenBSD ports tree.

Index: src/ssl/ssl.h
===
RCS file: /backup/mirrors/cvsync/src/lib/libssl/src/ssl/ssl.h,v
retrieving revision 1.42
diff -u -p -r1.42 ssl.h
--- src/ssl/ssl.h   25 May 2014 13:27:38 -  1.42
+++ src/ssl/ssl.h   29 May 2014 14:34:19 -
@@ -1364,14 +1364,6 @@ size_t SSL_get_peer_finished(const SSL *
 #define OpenSSL_add_ssl_algorithms()   SSL_library_init()
 #define SSLeay_add_ssl_algorithms()SSL_library_init()
 
-/* this is for backward compatibility */
-#if 0 /* NEW_SSLEAY */
-#define SSL_CTX_set_default_verify(a,b,c) SSL_CTX_set_verify(a,b,c)
-#define SSL_set_pref_cipher(c,n)   SSL_set_cipher_list(c,n)
-#define SSL_add_session(a,b)SSL_CTX_add_session((a),(b))
-#define SSL_remove_session(a,b)SSL_CTX_remove_session((a),(b))
-#define SSL_flush_sessions(a,b)SSL_CTX_flush_sessions((a),(b))
-#endif
 /* More backward compatibility */
 #define SSL_get_cipher(s) \
SSL_CIPHER_get_name(SSL_get_current_cipher(s))



libssl remove SSL_(set|get)_(time|timeout)

2014-05-29 Thread Alexander Schrijver
I'm not sure how much, and if this breaks anything in Ports.

According to github it isn't used much.

https://github.com/search?q=SSL_get_time+extension%3Ac+language%3Actype=Coderef=searchresults
https://github.com/search?q=SSL_set_time+extension%3Ac+language%3Actype=Coderef=searchresults
https://github.com/search?q=SSL_get_timeout+extension%3Ac+language%3Actype=Coderef=searchresults
https://github.com/search?q=SSL_set_timeout+extension%3Ac+language%3Actype=Coderef=searchresults


Index: src/ssl/ssl.h
===
RCS file: /backup/mirrors/cvsync/src/lib/libssl/src/ssl/ssl.h,v
retrieving revision 1.42
diff -u -p -r1.42 ssl.h
--- src/ssl/ssl.h   25 May 2014 13:27:38 -  1.42
+++ src/ssl/ssl.h   29 May 2014 15:03:22 -
@@ -1381,10 +1381,6 @@ size_t SSL_get_peer_finished(const SSL *
SSL_CIPHER_get_version(SSL_get_current_cipher(s))
 #define SSL_get_cipher_name(s) \
SSL_CIPHER_get_name(SSL_get_current_cipher(s))
-#define SSL_get_time(a)SSL_SESSION_get_time(a)
-#define SSL_set_time(a,b)  SSL_SESSION_set_time((a),(b))
-#define SSL_get_timeout(a) SSL_SESSION_get_timeout(a)
-#define SSL_set_timeout(a,b)   SSL_SESSION_set_timeout((a),(b))
 
 #define d2i_SSL_SESSION_bio(bp,s_id) 
ASN1_d2i_bio_of(SSL_SESSION,SSL_SESSION_new,d2i_SSL_SESSION,bp,s_id)
 #define i2d_SSL_SESSION_bio(bp,s_id) 
ASN1_i2d_bio_of(SSL_SESSION,i2d_SSL_SESSION,bp,s_id)
Index: src/doc/ssl/ssl.pod
===
RCS file: /backup/mirrors/cvsync/src/lib/libssl/src/doc/ssl/ssl.pod,v
retrieving revision 1.11
diff -u -p -r1.11 ssl.pod
--- src/doc/ssl/ssl.pod 13 Apr 2014 15:25:34 -  1.11
+++ src/doc/ssl/ssl.pod 29 May 2014 15:03:22 -
@@ -525,10 +525,6 @@ connection defined in the BSSL structu
 
 =item int BSSL_get_state(const SSL *ssl);
 
-=item long BSSL_get_time(const SSL *ssl);
-
-=item long BSSL_get_timeout(const SSL *ssl);
-
 =item int (*BSSL_get_verify_callback(const SSL *ssl))(int,X509_STORE_CTX *)
 
 =item int BSSL_get_verify_mode(const SSL *ssl);
@@ -606,10 +602,6 @@ connection defined in the BSSL structu
 =item void BSSL_set_shutdown(SSL *ssl, int mode);
 
 =item int BSSL_set_ssl_method(SSL *ssl, const SSL_METHOD *meth);
-
-=item void BSSL_set_time(SSL *ssl, long t);
-
-=item void BSSL_set_timeout(SSL *ssl, long t);
 
 =item void BSSL_set_verify(SSL *ssl, int mode, int (*callback);(void))
 
Index: src/doc/ssl/SSL_SESSION_get_time.pod
===
RCS file: 
/backup/mirrors/cvsync/src/lib/libssl/src/doc/ssl/SSL_SESSION_get_time.pod,v
retrieving revision 1.6
diff -u -p -r1.6 SSL_SESSION_get_time.pod
--- src/doc/ssl/SSL_SESSION_get_time.pod4 May 2014 21:13:41 -   
1.6
+++ src/doc/ssl/SSL_SESSION_get_time.pod29 May 2014 15:03:22 -
@@ -15,11 +15,6 @@ settings
  long SSL_SESSION_get_timeout(const SSL_SESSION *s);
  long SSL_SESSION_set_timeout(SSL_SESSION *s, long tm);
 
- long SSL_get_time(const SSL_SESSION *s);
- long SSL_set_time(SSL_SESSION *s, long tm);
- long SSL_get_timeout(const SSL_SESSION *s);
- long SSL_set_timeout(SSL_SESSION *s, long tm);
-
 =head1 DESCRIPTION
 
 SSL_SESSION_get_time() returns the time at which the session Bs was
@@ -34,9 +29,6 @@ in seconds.
 
 SSL_SESSION_set_timeout() sets the timeout value for session Bs in seconds
 to Btm.
-
-The SSL_get_time(), SSL_set_time(), SSL_get_timeout(), and SSL_set_timeout()
-functions are synonyms for the SSL_SESSION_*() counterparts.
 
 =head1 NOTES
 
Index: man/Makefile
===
RCS file: /backup/mirrors/cvsync/src/lib/libssl/man/Makefile,v
retrieving revision 1.25
diff -u -p -r1.25 Makefile
--- man/Makefile16 Apr 2014 09:50:10 -  1.25
+++ man/Makefile29 May 2014 15:03:22 -
@@ -206,10 +206,6 @@ MLINKS+=\
SSL_SESSION_get_time.3 SSL_SESSION_get_timeout.3 \
SSL_SESSION_get_time.3 SSL_SESSION_set_time.3 \
SSL_SESSION_get_time.3 SSL_SESSION_set_timeout.3 \
-   SSL_SESSION_get_time.3 SSL_get_time.3 \
-   SSL_SESSION_get_time.3 SSL_get_timeout.3 \
-   SSL_SESSION_get_time.3 SSL_set_time.3 \
-   SSL_SESSION_get_time.3 SSL_set_timeout.3 \
SSL_alert_type_string.3 SSL_alert_desc_string.3 \
SSL_alert_type_string.3 SSL_alert_desc_string_long.3 \
SSL_alert_type_string.3 SSL_alert_type_string_long.3 \



libssl cleanup

2014-05-25 Thread Alexander Schrijver
This diff boils down to: removing unused shit.

src/ssl/ssl_locl.h:
- FP_ICC isn't used anylonger.
- The fips function was removed.
- Those defines aren't used anylonger.

src/ssl/ssl_lib.c:
- That bit of code has been disabled since 1998 (and perhaps before, there is
  no archive). And the data structure has changed.

asn_mime.c:
- That appears superfluous to me.

asn1_par.c
- It took me a while to figure out why this was written in the first place.
  Perhaps at some point in time j was unused? Obviously it is superfluous now.

Index: src/ssl/ssl_locl.h
===
RCS file: /backup/mirrors/cvsync/src/lib/libssl/src/ssl/ssl_locl.h,v
retrieving revision 1.37
diff -u -p -u -r1.37 ssl_locl.h
--- src/ssl/ssl_locl.h  24 May 2014 12:44:48 -  1.37
+++ src/ssl/ssl_locl.h  25 May 2014 10:49:11 -
@@ -515,18 +515,9 @@ typedef struct sess_cert_st {
 } SESS_CERT;
 
 
-/*#define MAC_DEBUG*/
-
-/*#define ERR_DEBUG*/
-/*#define ABORT_DEBUG  */
-/*#define PKT_DEBUG 1   */
-/*#define DES_DEBUG*/
-/*#define DES_OFB_DEBUG*/
 /*#define SSL_DEBUG*/
 /*#define RSA_DEBUG*/ 
-/*#define IDEA_DEBUG   */ 
 
-#define FP_ICC  (int (*)(const void *,const void *))
 #define ssl_put_cipher_by_char(ssl,ciph,ptr) \
((ssl)-method-put_cipher_by_char((ciph),(ptr)))
 #define ssl_get_cipher_by_char(ssl,ptr) \
@@ -895,9 +886,5 @@ void ssl3_cbc_digest_record(const EVP_MD
 const unsigned char *data, size_t data_plus_mac_size,
 size_t data_plus_mac_plus_padding_size, const unsigned char *mac_secret,
 unsigned mac_secret_length, char is_sslv3);
-
-void tls_fips_digest_extra(const EVP_CIPHER_CTX *cipher_ctx,
-EVP_MD_CTX *mac_ctx, const unsigned char *data, size_t data_len,
-size_t orig_len);
 
 #endif
Index: src/ssl/ssl_lib.c
===
RCS file: /backup/mirrors/cvsync/src/lib/libssl/src/ssl/ssl_lib.c,v
retrieving revision 1.46
diff -u -p -u -r1.46 ssl_lib.c
--- src/ssl/ssl_lib.c   24 May 2014 18:34:03 -  1.46
+++ src/ssl/ssl_lib.c   25 May 2014 10:49:11 -
@@ -1771,10 +1771,6 @@ SSL_CTX_new(const SSL_METHOD *meth)
ret-references = 1;
ret-quiet_shutdown = 0;
 
-/* ret-cipher=NULL;
-   ret-master_key=NULL;
-*/
-
ret-info_callback = NULL;
 
ret-app_verify_callback = 0;
Index: src/crypto/asn1/asn_mime.c
===
RCS file: /backup/mirrors/cvsync/src/lib/libssl/src/crypto/asn1/asn_mime.c,v
retrieving revision 1.14
diff -u -p -u -r1.14 asn_mime.c
--- src/crypto/asn1/asn_mime.c  15 May 2014 21:07:10 -  1.14
+++ src/crypto/asn1/asn_mime.c  25 May 2014 10:49:11 -
@@ -999,7 +999,7 @@ strip_eol(char *linebuf, int *plen)
int len = *plen;
char *p, c;
int is_eol = 0;
-   p = linebuf + len - 1;
+
for (p = linebuf + len - 1; len  0; len--, p--) {
c = *p;
if (c == '\n')
Index: src/crypto/asn1/asn1_par.c
===
RCS file: /backup/mirrors/cvsync/src/lib/libssl/src/crypto/asn1/asn1_par.c,v
retrieving revision 1.16
diff -u -p -u -r1.16 asn1_par.c
--- src/crypto/asn1/asn1_par.c  19 Apr 2014 11:43:07 -  1.16
+++ src/crypto/asn1/asn1_par.c  25 May 2014 10:49:11 -
@@ -138,9 +138,7 @@ asn1_parse2(BIO *bp, const unsigned char
while ((p  tot)  (op  p)) {
op = p;
j = ASN1_get_object(p, len, tag, xclass, length);
-#ifdef LINT
-   j = j;
-#endif
+
if (j  0x80) {
if (BIO_write(bp, Error in encoding\n, 18) = 0)
goto end;



Use strdup

2014-05-25 Thread Alexander Schrijver
Use strdup instead of hand-rolling one.

Index: src/crypto/objects/obj_lib.c
===
RCS file: /backup/mirrors/cvsync/src/lib/libssl/src/crypto/objects/obj_lib.c,v
retrieving revision 1.8
diff -u -p -u -r1.8 obj_lib.c
--- src/crypto/objects/obj_lib.c19 Apr 2014 16:42:26 -  1.8
+++ src/crypto/objects/obj_lib.c25 May 2014 11:56:46 -
@@ -67,7 +67,6 @@ OBJ_dup(const ASN1_OBJECT *o)
 {
ASN1_OBJECT *r;
int i;
-   char *ln = NULL, *sn = NULL;
unsigned char *data = NULL;
 
if (o == NULL)
@@ -92,21 +91,15 @@ OBJ_dup(const ASN1_OBJECT *o)
r-nid = o-nid;
r-ln = r-sn = NULL;
if (o-ln != NULL) {
-   i = strlen(o-ln) + 1;
-   ln = malloc(i);
-   if (ln == NULL)
+   r-ln = strdup(o-ln);
+   if (r-ln == NULL)
goto err;
-   memcpy(ln, o-ln, i);
-   r-ln = ln;
}
 
if (o-sn != NULL) {
-   i = strlen(o-sn) + 1;
-   sn = malloc(i);
-   if (sn == NULL)
+   r-sn = strdup(o-sn);
+   if (r-sn == NULL)
goto err;
-   memcpy(sn, o-sn, i);
-   r-sn = sn;
}
r-flags = o-flags | (ASN1_OBJECT_FLAG_DYNAMIC |
ASN1_OBJECT_FLAG_DYNAMIC_STRINGS | ASN1_OBJECT_FLAG_DYNAMIC_DATA);



c_rehash doesn't exist.

2014-05-25 Thread Alexander Schrijver
c_rehash doesn't exist in OpenBSD and remove a history lesson which is either
not aplicable anymore or was never true.

Index: openssl.1
===
RCS file: /backup/mirrors/cvsync/src/usr.sbin/openssl/openssl.1,v
retrieving revision 1.93
diff -u -r1.93 openssl.1
--- openssl.1   13 Mar 2014 10:12:11 -  1.93
+++ openssl.1   25 May 2014 12:48:53 -
@@ -9072,11 +9072,6 @@
 option of the
 .Nm x509
 utility).
-Under
-.Ux ,
-the
-.Nm c_rehash
-script will automatically create symbolic links to a directory of certificates.
 .It Fl crl_check
 Checks end entity certificate validity by attempting to look up a valid CRL.
 If a valid CRL cannot be found an error occurs.
@@ -10403,27 +10398,6 @@
 It is hoped that it will represent reality in
 .Nm OpenSSL
 0.9.5 and later.
-.Sh X509 HISTORY
-Before
-.Nm OpenSSL
-0.9.8,
-the default digest for RSA keys was MD5.
-.Pp
-The hash algorithm used in the
-.Fl subject_hash
-and
-.Fl issuer_hash
-options before
-.Nm OpenSSL
-1.0.0 was based on the deprecated MD5 algorithm and the encoding
-of the distinguished name.
-In
-.Nm OpenSSL
-1.0.0 and later it is based on a canonical version of the DN using SHA1.
-This means that any directories using the old form
-must have their links rebuilt using
-.Ar c_rehash
-or similar.
 .\
 .\ FILES
 .\



Re: vmmap replacement -- please test

2012-01-03 Thread Alexander Schrijver
On Fri, Dec 30, 2011 at 05:55:27PM +0100, Ariane van der Steldt wrote:
 - it's only a 3^W 10494 line diff :P

Wow, you weren't kidding.

 I'll need testing on any and all architectures.

I'm now running this on my sparc64, macppc and amd64 boxes, the amd64 is the
only one i currently actually use, the others i'm just testing with make
build. 

I'll sent an e-mail if any of the machine does anything unexpected.



Re: vmmap replacement -- please test

2011-12-31 Thread Alexander Schrijver
On Fri, Dec 30, 2011 at 05:55:27PM +0100, Ariane van der Steldt wrote:
 I'll need testing on any and all architectures.

Is this in snapshots too?



lkm(4) streams implementation

2011-08-18 Thread Alexander Schrijver
Don't mention loadable streams modules are lacking.

OK?

Index: lkm.4
===
RCS file: /home/alex/scm/cvsync/src/share/man/man4/lkm.4,v
retrieving revision 1.15
diff -u -r1.15 lkm.4
--- lkm.4   2 Aug 2008 09:17:46 -   1.15
+++ lkm.4   18 Aug 2011 20:49:28 -
@@ -139,6 +139,3 @@
 .An Terrence R. Lambert Aq te...@cs.weber.edu
 .Sh BUGS
 Loading a bogus module is likely to kill your machine.
-.Pp
-Loadable streams modules should and will be implemented
-when a streams implementation is written.



grep(1) integer overflow

2011-07-17 Thread Alexander Schrijver
This fixes an integer overflow with very long lines.

OK?

Index: util.c
===
RCS file: /home/alex/scm/cvsync/src/usr.bin/grep/util.c,v
retrieving revision 1.41
diff -u -r1.41 util.c
--- util.c  11 Jul 2011 20:43:21 -  1.41
+++ util.c  17 Jul 2011 09:17:22 -
@@ -169,7 +169,7 @@
 {
regmatch_t  pmatch;
int c, i, r;
-   int offset;
+   size_t  offset;
 
c = 0;
i = 0;
@@ -444,7 +444,7 @@
 #ifdef SMALL
return 0;
 #else
-   int j;
+   size_t j;
int rtrnVal = REG_NOMATCH;
 
pmatch-rm_so = -1;



Re: issues with yacc/lex(er) from OpenBSD across my rules/grammer

2011-06-07 Thread Alexander Schrijver
Your keywords aren't sorted.

On Tue, Jun 7, 2011 at 12:09 PM, Rafael Sadowski raf...@sizeofvoid.orgwrote:

 On Wed Jun 01, 2011 at 11:03:46AM +0200, Otto Moerbeek wrote:
  On Wed, Jun 01, 2011 at 10:54:05AM +0200, Rafael Sadowski wrote:
 
   Hello @tech,
  
   I hope anybody can help my with my yacc rules/grammer. I can't find
 bugs
   in my grammer. I think the problem is in the lexer but I have no idea,
   how debug it. GDB tells me: No Source Available for yyparse (). Any
   advice, how debug it? This is my first experience with YACC!
  
   Maybe any yacc/lex hacker has a minute to look over my parse.y. I am
   grateful for any advice. My parse.y based on ospfd and relayd.
 
  Run yacc with -t and set yydebug = 1 in your code. That will reveal
  the tokens yacc sees and what it does with them.
 
-Otto
 

 Thanks Otto, this helped me a lot. Now, I'm one step big forward.

 I found one (In my opinion) strangeness in my grammeri/rule. It is
 important to declare the TOKEN in dependence to other TOKEN?

 It will not work with following rule, if I change WIRELESSNAME to
 NETMASK it works file. I don't know why, what is the different between
 WIRELESSNAME and NETMASK?


 wirelessoptsl   : WIRELESSNAME STRING '{' {
 }
 | PRIORITY NUMBER optnl {
 }
 '}'
;


 ### my tokes:

 %token NETWORK  ETHERNETNAME WIRELESSNAME
 %token BSSID CHANNEL DHCP DOMAINNAME DOMAINNAMESERVERS ERROR
 %token INCLUDE INET INTERFACE YES
 %token LLADDR MINSIGNAL NETMASK NWID NO PRIORITY RUNDOWN RUNUP
 %token UPDATEINTERVAL WEP WEPKEY
 %token WPA WPAAKMS WPACIPHERS WPAGROUPCIPHER WPAKEY
 %token  v.string  STRING
 %token  v.number  NUMBER
 %type   v.string  string

 ### my keywords:

static const struct keywords keywords[] = {
{ bssid,  BSSID },
{ channel,CHANNEL },
{ dhcp,   DHCP },
{ domain-name,DOMAINNAME },
{ domain-name-servers,DOMAINNAMESERVERS },
{ error,  ERROR },
{ ethernet,   ETHERNETNAME },
{ include,INCLUDE },
{ inet,   INET },
{ interface,  INTERFACE },
{ yes,YES },
{ lladdr, LLADDR },
{ minsignal,  MINSIGNAL },
{ netmask,NETMASK },
{ network,NETWORK },
{ nwid,   NWID },
{ no, NO },
{ priority,   PRIORITY },
{ run-down,   RUNDOWN },
{ run-up, RUNUP },
{ update_interval,UPDATEINTERVAL },
{ wireless,   WIRELESSNAME },
{ wep,WEP},
{ wepkey, WEPKEY},
{ wpa,WPA},
{ wpaakms,WPAAKMS },
{ wpaciphers, WPACIPHERS },
{ wpagroupcipher, WPAGROUPCIPHER },
{ wpakey, WPAKEY }
};
const struct keywords   *p;

 ### my config file (crashed with wireless, works with netmask):

 network local {
ethernet home {
priority 23
}
ethernet work {
priority 23
}
wireless park {
priority 23
}
 }

 --
 http://www.sizeofvoid.org - raf...@sizeofvoid.org
 XMPP: z...@jabber.ccc.de
 Key fingerprint: BDDD 91E9 28CB 3A52 3E99  61B0 C359 2691 BAC6 A3B1



Re: [patch] -H flag for grep.

2011-02-21 Thread Alexander Schrijver
On Mon, Feb 21, 2011 at 01:34:51PM +0100, Pascal Stumpf wrote:
 Implement a -H flag for grep, useful for combining e.g. find and grep.

-o used to do this but has been removed. (See the commit logs for the reason, i
forgot it)

grep(1) only prints the filename when it receives more then 1 filename as
arguments. Thus, when you do this:

$ find . -name '*.c' -exec grep bla {} \;

It doesn't print the filename.

But when you use xargs(1), like Bret suggests it does.



Re: Workaround for data corruption issue with ALI M5229 IDE chip used with Sun Blade 100/Netra X1.

2011-01-15 Thread Alexander Schrijver
On Sat, Jan 15, 2011 at 12:17:54PM +0100, Mark Kettenis wrote:
  Date: Fri, 14 Jan 2011 18:56:07 +0100
  From: Alexander Schrijver alexander.schrij...@gmail.com
  
   The big question of course is whether it will survive a make build
   with the change that removes the restriction of only using Ultra-DMA
   up to mode 2, but without the fixes in pciide.c.
   
   Beware, that might actually eat your filesystem.
   
  
  I'm doing this right now. I'm running a make build as we speak. I'm not sure
  when it should fuck up the filesystem.
 
 Me neither, that's what makes this diff so difficult to test properly.

So, make build failed with the following message. I'm not sure what is to blame
here.

I forgot to upgrade packages to the latest -current. AFAIK the build process
isn't dependend on external packages, but i'm not entirely sure if it could
accidentally use an externel package.

Looking at the commit logs nothing happened in /gnu/ in the last week so it
probably isn't the tree.

The boot filesystem checks went fine. Nothing new in dmesg either.

i'll run it again tomorrow with a decently upgraded system and a fresh 
/usr/src/.

I don't know anything about the perl build system so i can't really investigate
that. cvs diff says none of the files have changed in the perl directory.

The message with some stuff removed:

Running Makefile.PL in cpan/Encode

[ ... stuff removed ... ]

cp Encode/_PM.e2x ../../lib/Encode/_PM.e2x
cp lib/Encode/CJKConstants.pm ../../lib/Encode/CJKConstants.pm
make: don't know how to make ExtUtils/xsubpp. Stop in 
/usr/obj/gnu/usr.bin/perl/cpan/Encode.
Unsuccessful make(cpan/Encode): code=512 at make_ext.pl line 449.
*** Error code 25

Stop in /usr/src/gnu/usr.bin/perl/obj (line 695 of makefile).
*** Error code 1

Stop in /usr/src/gnu/usr.bin/perl (line 81 of 
/usr/src/gnu/usr.bin/perl/Makefile.bsd-wrapper).
*** Error code 1

Stop in /usr/src/gnu/usr.bin (line 48 of /usr/share/mk/bsd.subdir.mk).
*** Error code 1

Stop in /usr/src/gnu (line 48 of /usr/share/mk/bsd.subdir.mk).
*** Error code 1

Stop in /usr/src (line 48 of /usr/share/mk/bsd.subdir.mk).
*** Error code 1

Stop in /usr/src (line 74 of Makefile).

complete message:

=== gnu/usr.bin/perl
cd /usr/src/gnu/usr.bin/perl/obj  exec /bin/sh cflags.SH
Extracting cflags (with variable substitutions)
cd /usr/src/gnu/usr.bin/perl/obj  exec /bin/sh makeaperl.SH
Extracting makeaperl (with variable substitutions)
cd /usr/src/gnu/usr.bin/perl/obj  exec /bin/sh myconfig.SH
Extracting myconfig (with variable substitutions)
cd /usr/src/gnu/usr.bin/perl/obj  exec /bin/sh Policy_sh.SH
Extracting Policy.sh (with variable substitutions)
cd /usr/src/gnu/usr.bin/perl/obj/pod  exec /bin/sh Makefile.SH
Extracting pod/Makefile (with variable substitutions)
cd /usr/src/gnu/usr.bin/perl/obj/x2p  exec /bin/sh cflags.SH
Extracting x2p/cflags (with variable substitutions)
cc -O2 -pipe -g -fno-strict-aliasing -fno-delete-null-pointer-checks   
-DPERL_CORE -DPERL_RANDOM_DEVICE=/dev/arandom -I. -c 
/usr/src/gnu/usr.bin/perl/gv.c -o gv.o
cc -O2 -pipe -g -fno-strict-aliasing -fno-delete-null-pointer-checks   
-DPERL_CORE -DPERL_RANDOM_DEVICE=/dev/arandom -I. -c 
/usr/src/gnu/usr.bin/perl/toke.c -o toke.o
cc -O2 -pipe -g -fno-strict-aliasing -fno-delete-null-pointer-checks   
-DPERL_CORE -DPERL_RANDOM_DEVICE=/dev/arandom -I. -c perly.c -o perly.o
cc -O2 -pipe -g -fno-strict-aliasing -fno-delete-null-pointer-checks   
-DPERL_CORE -DPERL_RANDOM_DEVICE=/dev/arandom -I. -c 
/usr/src/gnu/usr.bin/perl/pad.c -o pad.o
cc -O2 -pipe -g -fno-strict-aliasing -fno-delete-null-pointer-checks   
-DPERL_CORE -DPERL_RANDOM_DEVICE=/dev/arandom -I. -c 
/usr/src/gnu/usr.bin/perl/regcomp.c -o regcomp.o
cc -O2 -pipe -g -fno-strict-aliasing -fno-delete-null-pointer-checks   
-DPERL_CORE -DPERL_RANDOM_DEVICE=/dev/arandom -I. -c 
/usr/src/gnu/usr.bin/perl/dump.c -o dump.o
cc -O2 -pipe -g -fno-strict-aliasing -fno-delete-null-pointer-checks   
-DPERL_CORE -DPERL_RANDOM_DEVICE=/dev/arandom -I. -c 
/usr/src/gnu/usr.bin/perl/util.c -o util.o
cc -O2 -pipe -g -fno-strict-aliasing -fno-delete-null-pointer-checks   
-DPERL_CORE -DPERL_RANDOM_DEVICE=/dev/arandom -I. -c 
/usr/src/gnu/usr.bin/perl/mg.c -o mg.o
cc -O2 -pipe -g -fno-strict-aliasing -fno-delete-null-pointer-checks   
-DPERL_CORE -DPERL_RANDOM_DEVICE=/dev/arandom -I. -c 
/usr/src/gnu/usr.bin/perl/reentr.c -o reentr.o
cc -O2 -pipe -g -fno-strict-aliasing -fno-delete-null-pointer-checks   
-DPERL_CORE -DPERL_RANDOM_DEVICE=/dev/arandom -I. -c 
/usr/src/gnu/usr.bin/perl/mro.c -o mro.o
cc -O2 -pipe -g -fno-strict-aliasing -fno-delete-null-pointer-checks   
-DPERL_CORE -DPERL_RANDOM_DEVICE=/dev/arandom -I. -c 
/usr/src/gnu/usr.bin/perl/hv.c -o hv.o
cc -O2 -pipe -g -fno-strict-aliasing -fno-delete-null-pointer-checks   
-DPERL_CORE -DPERL_RANDOM_DEVICE=/dev/arandom -I. -c 
/usr/src/gnu/usr.bin/perl/av.c -o av.o
cc -O2 -pipe -g -fno-strict-aliasing -fno-delete-null-pointer-checks   
-DPERL_CORE -DPERL_RANDOM_DEVICE=/dev/arandom -I. -c

Re: Workaround for data corruption issue with ALI M5229 IDE chip used with Sun Blade 100/Netra X1.

2011-01-14 Thread Alexander Schrijver
 The big question of course is whether it will survive a make build
 with the change that removes the restriction of only using Ultra-DMA
 up to mode 2, but without the fixes in pciide.c.
 
 Beware, that might actually eat your filesystem.
 

I'm doing this right now. I'm running a make build as we speak. I'm not sure
when it should fuck up the filesystem.

before:

pciide0 at pci0 dev 13 function 0 Acer Labs M5229 UDMA IDE rev 0xc3: DMA, 
channel 0 configured to native-PCI, channel 1 configured to native-PCI
pciide0: using ivec 0x7cc for native-PCI interrupt
wd0 at pciide0 channel 0 drive 0: ST340014A
wd0: 16-sector PIO, LBA48, 38166MB, 78165360 sectors
wd0(pciide0:0:0): using PIO mode 4, Ultra-DMA mode 2
wd1 at pciide0 channel 1 drive 0: ST340014A
wd1: 16-sector PIO, LBA48, 38166MB, 78165360 sectors
wd1(pciide0:1:0): using PIO mode 4, Ultra-DMA mode 2

after:

pciide0: using ivec 0x7cc for native-PCI interrupt
wd0 at pciide0 channel 0 drive 0: ST340014A
wd0: 16-sector PIO, LBA48, 38166MB, 78165360 sectors
wd0(pciide0:0:0): using PIO mode 4, Ultra-DMA mode 4
wd1 at pciide0 channel 1 drive 0: ST340014A
wd1: 16-sector PIO, LBA48, 38166MB, 78165360 sectors
wd1(pciide0:1:0): using PIO mode 4, Ultra-DMA mode 4

diff i used:

Index: arch/sparc64/conf/GENERIC
===
RCS file: /home/cvs/src/sys/arch/sparc64/conf/GENERIC,v
retrieving revision 1.261
diff -u -p -r1.261 GENERIC
--- arch/sparc64/conf/GENERIC   12 Dec 2010 14:33:57 -  1.261
+++ arch/sparc64/conf/GENERIC   11 Jan 2011 23:41:06 -
@@ -381,7 +381,7 @@ stty*   at spif?
 sbpp*  at spif?
 
 pciide*at pci? flags 0x
-wd*at pciide? flags 0x0a00
+wd*at pciide? flags 0x
 atapiscsi* at pciide?
 scsibus* at atapiscsi?
 
Index: arch/sparc64/conf/RAMDISK
===
RCS file: /home/cvs/src/sys/arch/sparc64/conf/RAMDISK,v
retrieving revision 1.98
diff -u -p -r1.98 RAMDISK
--- arch/sparc64/conf/RAMDISK   19 Apr 2010 10:44:33 -  1.98
+++ arch/sparc64/conf/RAMDISK   11 Jan 2011 23:41:13 -
@@ -151,7 +151,7 @@ ti* at sbus?
 gem*   at sbus?
 
 pciide*at pci? flags 0x
-wd*at pciide? flags 0x0a00
+wd*at pciide? flags 0x
 atapiscsi* at pciide?
 scsibus* at atapiscsi?
 
Index: arch/sparc64/conf/RAMDISKU5
===
RCS file: /home/cvs/src/sys/arch/sparc64/conf/RAMDISKU5,v
retrieving revision 1.16
diff -u -p -r1.16 RAMDISKU5
--- arch/sparc64/conf/RAMDISKU5 24 Jun 2009 11:38:40 -  1.16
+++ arch/sparc64/conf/RAMDISKU5 11 Jan 2011 23:41:30 -
@@ -55,7 +55,7 @@ pcons0at mainbus0 # PROM console
 timer* at mainbus0 # Timer chip (some systems)
 
 pciide*at pci? flags 0x
-wd*at pciide? flags 0x0a00
+wd*at pciide? flags 0x
 atapiscsi* at pciide?
 scsibus* at atapiscsi?



uticom firmware

2010-12-16 Thread Alexander Schrijver
This diff makes the uticom(4) driver work on my machine with an Abbott USB
converter, which is used to connect to the Abbott Freestyle series glucose
meter.

This makes the firmware loading work again.

Index: usbdevs
===
RCS file: /home/cvsync/src/sys/dev/usb/usbdevs,v
retrieving revision 1.531
diff -u -r1.531 usbdevs
--- usbdevs 15 Dec 2010 16:49:03 -  1.531
+++ usbdevs 16 Dec 2010 21:38:55 -
@@ -548,6 +548,7 @@
 vendor ZTE 0x19d2  ZTE Inc.
 vendor QUANTA  0x1a32  Quanta
 vendor TERMINUS0x1a40  Terminus Technology
+vendor ABBOTT  0x1a61  Abbott Labs
 vendor BAYER   0x1a79  Bayer Health Care
 vendor WCH20x1a86  QinHeng Electronics
 vendor MATRIXORB   0x1b3d  Matrix Orbital
@@ -635,6 +636,9 @@
 product 3COMUSR USR56K 0x3021  U.S.Robotics 56000
 
 product HUAWEI3COM WUB320G 0x0009  Aolynk WUB320g
+
+/* Abbott products */
+product ABBOTT STEREO_PLUG 0x3410  Stereo Plug Cable
 
 /* AboCom products */
 product ABOCOM XX1 0x110c  XX1
Index: usbdevs.h
===
RCS file: /home/cvsync/src/sys/dev/usb/usbdevs.h,v
retrieving revision 1.541
diff -u -r1.541 usbdevs.h
--- usbdevs.h   15 Dec 2010 16:51:39 -  1.541
+++ usbdevs.h   16 Dec 2010 21:38:55 -
@@ -1,4 +1,4 @@
-/* $OpenBSD: usbdevs.h,v 1.541 2010/12/15 16:51:39 damien Exp $*/
+/* $OpenBSD$   */
 
 /*
  * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
@@ -555,6 +555,7 @@
 #defineUSB_VENDOR_ZTE  0x19d2  /* ZTE Inc. */
 #defineUSB_VENDOR_QUANTA   0x1a32  /* Quanta */
 #defineUSB_VENDOR_TERMINUS 0x1a40  /* Terminus Technology 
*/
+#defineUSB_VENDOR_ABBOTT   0x1a61  /* Abbott Labs */
 #defineUSB_VENDOR_BAYER0x1a79  /* Bayer Health Care */
 #defineUSB_VENDOR_WCH2 0x1a86  /* QinHeng Electronics */
 #defineUSB_VENDOR_MATRIXORB0x1b3d  /* Matrix Orbital */
@@ -642,6 +643,9 @@
 #defineUSB_PRODUCT_3COMUSR_USR56K  0x3021  /* U.S.Robotics 
56000 */
 
 #defineUSB_PRODUCT_HUAWEI3COM_WUB320G  0x0009  /* Aolynk 
WUB320g */
+
+/* Abbott products */
+#defineUSB_PRODUCT_ABBOTT_STEREO_PLUG  0x3410  /* Stereo Plug 
Cable */
 
 /* AboCom products */
 #defineUSB_PRODUCT_ABOCOM_XX1  0x110c  /* XX1 */
Index: usbdevs_data.h
===
RCS file: /home/cvsync/src/sys/dev/usb/usbdevs_data.h,v
retrieving revision 1.535
diff -u -r1.535 usbdevs_data.h
--- usbdevs_data.h  15 Dec 2010 16:51:39 -  1.535
+++ usbdevs_data.h  16 Dec 2010 21:38:55 -
@@ -1,4 +1,4 @@
-/* $OpenBSD: usbdevs_data.h,v 1.535 2010/12/15 16:51:39 damien Exp $   
*/
+/* $OpenBSD$   */
 
 /*
  * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
@@ -118,6 +118,10 @@
Aolynk WUB320g,
},
{
+   USB_VENDOR_ABBOTT, USB_PRODUCT_ABBOTT_STEREO_PLUG,
+   Stereo Plug Cable,
+   },
+   {
USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX1,
XX1,
},
@@ -11716,6 +11720,10 @@
{
USB_VENDOR_TERMINUS,
Terminus Technology,
+   },
+   {
+   USB_VENDOR_ABBOTT,
+   Abbott Labs,
},
{
USB_VENDOR_BAYER,
Index: uticom.c
===
RCS file: /home/cvsync/src/sys/dev/usb/uticom.c,v
retrieving revision 1.10
diff -u -r1.10 uticom.c
--- uticom.c15 Dec 2010 16:22:16 -  1.10
+++ uticom.c16 Dec 2010 21:38:55 -
@@ -119,7 +119,7 @@
 };
 
 struct uticom_softc {
-   struct devicesc_dev;/* base device */
+   struct devicesc_dev;/* base device */
usbd_device_handle   sc_udev;   /* device */
usbd_interface_handlesc_iface;  /* interface */
 
@@ -158,6 +158,8 @@
 static int  uticom_open(void *, int);
 static void uticom_close(void *, int);
 
+void uticom_attach_hook(void *arg);
+
 static int uticom_download_fw(struct uticom_softc *sc, int pipeno,
usbd_device_handle dev);
 
@@ -191,7 +193,8 @@
 
 static const struct usb_devno uticom_devs[] = {
{ USB_VENDOR_TI, USB_PRODUCT_TI_TUSB3410 },
-   { USB_VENDOR_STARTECH, USB_PRODUCT_STARTECH_ICUSB232X }
+   { USB_VENDOR_STARTECH, USB_PRODUCT_STARTECH_ICUSB232X },
+   { USB_VENDOR_ABBOTT, USB_PRODUCT_ABBOTT_STEREO_PLUG }
 };
 
 int
@@ -209,26 +212,37 @@
 void
 uticom_attach(struct device *parent, struct device *self, void *aux)
 {
-   struct uticom_softc *sc = (struct uticom_softc *)self;
-   struct usb_attach_arg *uaa = aux;
-   usbd_device_handle dev = uaa-device;
-   usb_config_descriptor_t *cdesc;
-   

Re: Missing check in ftp(1)

2010-06-27 Thread Alexander Schrijver
On Sun, Jun 27, 2010 at 02:04:27AM +0200, Peter Hessler wrote:
 Hi Alexander
 
 This diff had some issues for me, namely the chunk below.
 
 :+   if (line == NULL);
 
 
 However I did adjust it and came up with this instead, does it also fix
 the issue for you?

Ugh, that was real sloppy of me. Yes that actually fixes the issue. The fix i 
intended didn't.

Now it just does nothing, like it is supposed to (The second is with your fix 
applied):

$ echo 'mget -r . ' | ftp ftp://ftp.cs.cmu.edu 
Segmentation fault (core dumped) 
$ echo 'mget -r . ' | ./ftp ftp://ftp.cs.cmu.edu
$ 



Missing check in ftp(1)

2009-12-28 Thread Alexander Schrijver
If the directory entry isn't complete line can be NULL.

I ran into it using 'mget -r .' on this FTP server:

ftp://ftp.cs.cmu.edu

Index: list.c
===
RCS file: /home/cvsync/src/usr.bin/ftp/list.c,v
retrieving revision 1.3
diff -u -r1.3 list.c
--- list.c  5 May 2009 19:35:30 -   1.3
+++ list.c  29 Dec 2009 00:55:47 -
@@ -34,6 +34,8 @@
*type = *tok;

if (field == 7) {
+   if (line == NULL);
+   break;
while (**line == ' ' || **line == '\t')
(*line)++;
break;
@@ -58,6 +60,8 @@
*type = 'd';

if (field == 2) {
+   if (line == NULL);
+   break;
while (**line == ' ' || **line == '\t')
(*line)++;
break;