NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: bin/47154
It would post many times, I'm sorry.
2014-11-02 0:20 GMT+09:00 Miwa Susumu <miwarin%gmail.com@localhost>:
> The following reply was made to PR bin/47154; it has been noted by GNATS.
>
> From: Miwa Susumu <miwarin%gmail.com@localhost>
> To: gnats-bugs%netbsd.org@localhost, gnats-admin%netbsd.org@localhost, netbsd-bugs%netbsd.org@localhost,
> ben%hl9.neta@localhost
> >
> > I was modified to check the arguments before malloc().
> >
>
> my source code looks like it was older.
> I should use the current....
% uname -msr
NetBSD 7.99.1 i386
Again I will die here.
dd.c setup()
if (!(ddflags & (C_BLOCK|C_UNBLOCK))) {
size_t dbsz = out.dbsz;
if (!(ddflags & C_BS))
dbsz += in.dbsz - 1;
if ((in.db = malloc(dbsz)) == NULL) { <====
err(EXIT_FAILURE, NULL);
/* NOTREACHED */
}
out.db = in.db;
By the way Do you know behavior of malloc?
example:
4294967295u (SIZE_T_MAX) is an error. that's ok.
4293918720u (4095m) segmetation fault. It is not an error.
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
int main(int ac, char** av)
{
char* buf0;
char* buf1;
buf0 = malloc( 4294967295u );
if(buf0 == NULL) printf("%s\n", strerror(errno));
if(buf0 != NULL) free(buf0);
buf1 = malloc( 4293918720u );
if(buf1 == NULL) printf("%s\n", strerror(errno));
if(buf1 != NULL) free(buf1);
return 0;
}
4293918720u is 4294967295u smaller.
However, why do you not in error?
Home |
Main Index |
Thread Index |
Old Index