Thursday, November 17, 2016

Making lshw, IBM PowerPC compliant

Dear Linux Community,

The first tool that comes to mind when we think of obtaining hardware inventory on a computer is lshw, a concise tool leveraging C++ capabilities which already generates good results when run on a number of platforms, including x86.

lshw, like other cross-platform tools has generic code portions which are same across all platforms and some platform-specific code portions.

I am glad to tell that efforts to make lshw display correct and accurate platform-specific results when run on IBM PowerPC server systems running Linux are paying off as code-changes are getting merged upstream:
https://ezix.org/src/pkg/lshw/commits/master/search?q=Chandni+Verma
https://ezix.org/src/pkg/lshw/commits/master/search?q=Jack+Miller
https://ezix.org/src/pkg/lshw/commits/master/search?q=Jeremy+Kerr
https://ezix.org/src/pkg/lshw/commits/master/search?q=Vasant+Hegde

Update:
[
My other notable commits(despite of not retaining the Author name and signoff tag) include:
https://ezix.org/src/pkg/lshw/commit/d15668eb9569fd7d8259c3b5ca669781081d81c7
and
https://ezix.org/src/pkg/lshw/commit/27b1d1d18696be949dbe0b8a1639c5683de4ca8f
]

I'd like to thank lshw maintainer, Lyonel Vincent, here for acknowledging and accepting the changes.

Research is ongoing on abilities that are required but are lacking in the generic code as well and some of those require deep knowledge of ioctls, SCSI, SAS etc. and their workings. We're seeing how to expose more of those hardware inventory (encapsulated by certain subsystems) along with their location-codes and Vital Product Data (VPD) to the users so watch the above spaces and keep your systems updated!

Cheers,
Happy Hacking!

Wednesday, August 24, 2016

Learning Python!

Here are my first few basic Python programs (before my first Python assignment consuming and processing perf samples). :)


1)
#!/usr/bin/python
i = raw_input()
print i

2)
#!/usr/bin/python
T = int(raw_input())
print "Range of t is", range(T)
for i in range(T):
    print i
    ans = 42
    print "Case #%d: %d" % (i+1, ans)
    
3)
#!/usr/bin/python
T = int(raw_input())
for i in range(T):
    line = raw_input()
    N, J = line.split()
    N, J = int(N), int(J)
    print "N = %d, J = %d" % (N, J)   

4)
#!/usr/bin/python
T = int(raw_input())
i = 1
while i<=T:
    tmp = raw_input()
    N = int (tmp.split()[0])
    J = int (tmp.split()[1])
    print N, J
    print 2**N
    print 2**N-1
    print bin(2**N-1)
    i +=1   

5)
#!/usr/bin/python
#program 5
T = int(raw_input())
i = 1
while i<=T:
    tmp = raw_input()
    N = int (tmp.split()[0])
    J = int (tmp.split()[1])
    print N, J
    print 2**N
    print 2**N-1
    print bin(2**N-1)
    s = bin(2**N-1)[2:]
    print int(s, 2)
    print int(s, 3)
    print int(s, 4)
    print int(s, 10)
    i+=1      

6)
#!/usr/bin/python
 
#program 6
#defining functions
def factorial(n):
    ret = 1
    for i in range(n):
        ret *= i+1
     
    return ret
 
print factorial(5)
print factorial(4), factorial(3)

Friday, July 15, 2016

Secure C/C++ Coding practices

Dear Software Engineers and Amateur Programmers,

In today's scenario, writing secure code is not a choice anymore, it's a necessity.

As a result of me attending Paul Ionescu's webcast "Inside the mind of a Hacker" (https://t.co/YjqiJpn7lE) (where he talks about how crackers crack their way through your code and what loopholes and vulnerabilities they exploit) and being trained overtime with strong review comments from peers laying emphasis on secure programming, I've begun giving a keen eye to best coding practices.

One such link I googled for yesterday and thought of sharing is:

The following usage in the correctly marked answer there:
strncpy(buff, "String 1", BUFFER_SIZE - 1);
buff[BUFFER_SIZE - 1] = '\0';
is actually correct and not incorrect as pointed out by one of the commenters. See for yourself to know why!
(I couldn't add a comment there due to lack of enough points to comment on StackOverflow.)

I found many instances of insecure invocation of strncpy in the open source package I am currently working on like
strncpy(buff, "String 1", sizeof(buf));
and wanted to give a alert to the maintainers/programmers if they are using such lines often in their code so that they stop making this mistake.

Will keep posting updates in this space with more such important links.

Till then,
Cheers and Happy Coding!