Re: cvs: php4 /ext/dba dba.c
| From: | Jani Taskinen | Date: | Sun, 03 Dec 2000 23:55:50 +0000 |
| Subject: | Re: cvs: php4 /ext/dba dba.c | ||
| References: | 1 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-2910@lists.php.net to get a copy of this message | ||
On Fri, 1 Dec 2000, Sascha Schumann wrote:
> Please avoid potential buffer overflows in new code. If you deal
> with strings, consider storing the string length along with the string
> data. That will make your life easier.
Sorry for this bad commit. I promise I won't try to code anything
anymore when I have fever and bad flu..:(
>
>+#include "ext/standard/php_smart_str.h"
>
> static PHP_MINFO_FUNCTION(dba)
> {
> dba_handler *hptr;
>- static char handlers[80], tmp[5];
>+ smart_str handlers = {0};
>
> for(hptr = handler; hptr->name; hptr++) {
>- sprintf(tmp, "%s ", hptr->name);
>- strcat(handlers, tmp);
>+ smart_str_appends(&handlers, hptr->name);
>+ smart_str_appendc(&handlers, ' ');
> }
Shoudn't the string be ended with '\0' ??
Like this:
smart_str_appendc(&handlers, '\0');
And should these smart_str_*() funcs be used always instead
of strcat() and friends?
There seems to be strcat() used also in ext/db/db.c for same
purpose. Shouldn't it be 'smart_str'ed' too?
--Jani